[Omaha.pm] regex'ing binary goo??

Daniel Linder dan at linder.org
Wed Aug 30 08:26:11 PDT 2006


On Tue, August 29, 2006 10:54, Jay Hannah wrote:
> $ cat j.pl
> my $stream = "A00010\x{1b}\x{be}\x{a}\x{81}D00318";
> if ($stream =~ /^A00010.{4}/) {
>    print "yes\n";
> } else {
>    print "no\n";
> }
>
> $ perl j.pl
> no
>
>
> What??  That string doesn't start with A00010 followed by 4 somethings?

I beleve that the "\x{a}" is kicking you -- isn't that the hex character
"0xA" or "newline"?  Thus, your "$stream" variable is actually two lines
as far as the regexp is concerned.

(If I mis-read the \x{a} and/or mis-understood regexp and multi-line
matching, just ignore this...)

Dan

- - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computers, I fear the lack of them." -- Isaac Asimov
"Soon we will be able to harness the rotational energy from Orwell's grave
to solve all world energy problems." -- /. user GigsVT (208848)
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF  2EE0 B2B0 CC47 4FDE 9B68



More information about the Omaha-pm mailing list