mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-21 21:40:19 +02:00
29 lines
417 B
Plaintext
29 lines
417 B
Plaintext
|
#!/usr/bin/perl
|
||
|
sub usage
|
||
|
{
|
||
|
print STDERR "usage: $0 [-g] [file ...]\n";
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
if ($ARGV[0] eq "-g") {
|
||
|
$grep = 1;
|
||
|
shift @ARGV;
|
||
|
}
|
||
|
&usage if $ARGV[0] =~ /^-/;
|
||
|
|
||
|
while (<>) {
|
||
|
@c = unpack "C*";
|
||
|
for (@c) {
|
||
|
if ($_ == 10) {
|
||
|
print "$s\n" if $found || !$grep;
|
||
|
$found = 0;
|
||
|
undef $s;
|
||
|
} elsif ($_ < 0x80) {
|
||
|
$s .= pack("c", $_);
|
||
|
} else {
|
||
|
$s .= sprintf("\e[7m%02x\e[0m", $_);
|
||
|
$found = 1;
|
||
|
}
|
||
|
}
|
||
|
}
|