in reply to Re: Portable way to extract string from a binary
in thread Portable way to extract string from a binary
To match strings(1) as I'm used to, you'd want something like:
my( $min, $max ) = ( 4, 32*1024 ); local( $/ ) = \(32*1024); my $prev = ''; while( <> ) { $prev .= $_; while( $prev =~ /([\n\t -~]{$min,$max})\0/g ) { print "$1\n"; } $prev =~ s/.*\0//s; }
Though I notice that strings(1) on FreeBSD replaces the "followed by '\0'" with "followed by an unprintable character", which my testing finds to be a disadvantage (at least it should be made optional).
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Portable way to extract string from a binary (strings.pl)
by tachyon (Chancellor) on Jul 15, 2004 at 01:29 UTC |