perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
The string is searchable with grep which displays the binary garbage before and after with. My first attempt was to read in the file on stdin, and search for my target and use patterns before and after to display the entire path like:<binary>/etc/alternatives/aclocal<binary>C:\etc\alternatives\aclocal<e +of>
Unfortunately, life was not so simple. Even though the pattern works under "grep":$pathchrs => '[-\/\.[:alnum:]_]'; $target = 'aclocal' while(<>){ /(\/$pathchrs*$target$path*)/o && print "$1\n"; }
perl (and pcregrep) don't seem to find it.grep -a '/[-\/\.[:alnum:]_]*aclocal[-\/\.[:alnum:]_]*' /bin/aclocal +.lnk
FWIW - I made it work by splitting input into a buffer and removing non-printables, but that's hardly an efficient use of perl.
Why didn't the simpler approach work? Thanks for perls of wisdom...:-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to read & search in a binary file
by GrandFather (Saint) on Jan 30, 2007 at 00:35 UTC | |
|
Re: how to read & search in a binary file
by Tanktalus (Canon) on Jan 30, 2007 at 00:18 UTC | |
by perl-diddler (Chaplain) on Jan 30, 2007 at 07:17 UTC | |
|
Re: how to read & search in a binary file
by bart (Canon) on Jan 30, 2007 at 07:03 UTC |