From 4231e55a1bca84c55a53748944bcd7bada4689ec Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 21 Sep 2016 02:38:57 -0400 Subject: add a couple more perl utils --- dumpbytes.pl | 22 ++++++++++++++++++++++ grepbytes.pl | 9 +++++++++ 2 files changed, 31 insertions(+) create mode 100644 dumpbytes.pl create mode 100644 grepbytes.pl diff --git a/dumpbytes.pl b/dumpbytes.pl new file mode 100644 index 0000000..baa3d20 --- /dev/null +++ b/dumpbytes.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl -w + +$count = 0; +while(<>) { + $_ = substr($_, 0, 79); + s/.*; \w\w\w\w // or next; + my @bytes = split " "; + push @got, eval "0x$_" for @bytes; +} + +for(@got) { + my $b = sprintf("%08b", $_); + $b =~ s/0/_/g; + $b =~ s/1/X/g; + printf "%02x ", $_; + print $b . "\n"; + $count++; + if($count == 10) { + print "\n"; + $count = 0; + } +} diff --git a/grepbytes.pl b/grepbytes.pl new file mode 100644 index 0000000..f356278 --- /dev/null +++ b/grepbytes.pl @@ -0,0 +1,9 @@ +#!/usr/bin/perl -w + +$regex = shift or die "no regex"; +undef $/; +$_ = <>; + +while($_ =~ /$regex/gc) { + printf "match at \$%04X\n", $-[0] + 0x8000; +} -- cgit v1.2.3