Skip to content

Instantly share code, notes, and snippets.

@binary132
Created April 22, 2013 18:17
Show Gist options
  • Select an option

  • Save binary132/5437239 to your computer and use it in GitHub Desktop.

Select an option

Save binary132/5437239 to your computer and use it in GitHub Desktop.

Revisions

  1. binary132 created this gist Apr 22, 2013.
    20 changes: 20 additions & 0 deletions hexdump.pl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/usr/local/bin/perl

    # Bodie Solomon 2013
    # question 2: hex dump

    use strict;
    use warnings;

    {
    local $/ = \16;
    while (<>) {
    printf "%08d: %08X %08X %08X %08X %s\n",
    10 * ($.-1),
    vec($_, 0, 32),
    vec($_, 1, 32),
    vec($_, 2, 32),
    vec($_, 3, 32),
    do{ (my $str = $_) =~ s/[^!-~]/\./g; $str };
    }
    }