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

Jay Hannah jhannah at omnihotels.com
Tue Aug 29 11:03:01 PDT 2006


Andy was right... Apparently '.' doesn't match a bunch of binary goo.
Throw the /s switch on your regex though and it seems to do what I
expected. I've used /s a million times, but never in the context of
embedded random binary crap in my scalars...


$ cat j.pl
foreach (
   "A00010\x{1b}\x{be}\x{a}\x{81}D00318",
   "A00010\x{a}\x{1c}\x{10}hD00318"
) {
   print (/^A00010.{4}/  ? "yes " : "no ");
   print (/^A00010.{4}/s ? "yes " : "no ");
}
print "\n";

$ perl j.pl
no yes no yes


/s is my friend. :)

j



More information about the Omaha-pm mailing list