in reply to Looking for a hexadecimal byte string in a scalar variable
No need to use an array slice. You can do something like this:
if ($chunk =~ /^\xff\xff\x08\x00/) { print "Chunk in use\n"; } else { print "Chunk not used\n"; }
There's an example of doing similar things with PNG files in chapter 7 of Data Munging with Perl.
update: Fair point. Anchor added.
--
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Looking for a hexadecimal byte string in a scalar variable
by ton (Friar) on Apr 04, 2001 at 22:13 UTC |