in reply to Extract chunked/gzip data from pcap file

Note that in a statement like
    if ($data =~ /some text/g) { ... }
the  /g regex modifier does nothing Update: See ikegami's correction. In boolean context, you only care if the pattern matched or did not match. Given the regex of the example, you cannot distinguish if the regex matched once or more than once (although a different regex could determine this).

See g in the Modifiers section of perlre.

Replies are listed 'Best First'.
Re^2: Extract chunked/gzip data from pcap file (OT: Regex Usage)
by ikegami (Patriarch) on Dec 28, 2009 at 15:27 UTC
    If it did nothing, it would be harmless. Quite the opposite, it's a bug to use it there.
    >perl -le"for (1..2) { print 'ab' =~ /a/g ? 'match' : 'no match' }" match no match

      Thank you for pointing out my error, AnomalousMonk and ikegami. I was misapplying /g because I mistakenly thought it was necessary when matching against multi-line data. I have removed /g from my program.