hexdump.pl

Sometimes you just need a good, simple hex dumper. Like cronolog.pl I had a need for a quick-and-dirty hex dumper that I could cut and paste into a shell for those machines that don't have one installed by default but do have a Perl interpreter (OpenBSD, for example). Its output is similar to "hexdump -C myfile" in BSD Unix:


00000000 00000000    23 21 2f 75 73 72 2f 62 69 6e 2f 70 65 72 6c 0a    |  #!/usr/bin/perl.  |
00000016 00000010    0a 24 42 59 54 45 53 5f 50 45 52 5f 4c 49 4e 45    |  .$BYTES_PER_LINE  |
00000032 00000020    20 3d 20 31 36 3b 0a 23 20 30 30 30 30 30 30 30    |   = 16;.# 0000000  |
00000048 00000030    30 20 30 30 30 30 30 30 30 30 20 20 20 20 32 33    |  0 00000000    23  |
00000064 00000040    20 32 31 20 32 66 20 37 35 20 37 33 20 37 32 20    |   21 2f 75 73 72   |
00000080 00000050    32 66 20 36 32 20 36 39 20 36 65 20 32 66 20 37    |  2f 62 69 6e 2f 7  |


That's the address in dec, the address in hex, the bytes in hex, and the corresponding ascii characters. The code is simple and very easy to alter to fit your needs (probably easier than writing a formatting spec for the BSD "hexdump".)

The code is HERE. Enjoy.