Created
April 22, 2013 18:17
-
-
Save binary132/5437239 to your computer and use it in GitHub Desktop.
Hex dump STDIN to STDOUT, with byte index and ASCII text display.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 }; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment