Write both hex and char representation side by side.

Replace non-printing chars by ".".
use strict;
use locale;

in short: Almost completely new :-)
This commit is contained in:
hjp 2002-01-22 15:24:09 +00:00
parent 861c35e4db
commit 08a6803030
1 changed files with 14 additions and 7 deletions

View File

@ -1,15 +1,22 @@
#!/usr/bin/perl #!/usr/bin/perl -w
use strict;
use POSIX;
use locale;
$| = 1;
while(<>) { while(<>) {
if (/^\t\t\t( [0-9a-f]{2,4})+$/) { if (/^\t\t\t( [0-9a-f]{2,4})+$/) {
@hex = split; chomp;
foreach $i (@hex) { my @hex = split;
@c = pack("H4", $i); my $line = "$_ ";
foreach $j (@c) { foreach my $i (@hex) {
print "$j"; my @c = pack("H4", $i);
foreach my $j (split(//, "@c")) {
$line .= isprint($j) ? "$j" : ".";
} }
} }
print "\n"; print "$line\n";
} else { } else {
print print
} }