Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • You reset $str2 (in essence) on every loop, but you continually match against the same $str.

    So if you unroll your loops, you get basically this.

    Look for, at the beginning of the string, "J:", followed by a bunch of stuff that isn't a newline. (.+ with /m). Did you succeed? Remember this spot and proceed.

    Look for, at the beginning of the string (where we left off), "I:", followed by a bunch of stuff that isn't a newline. Did you succeed? *Remember this spot and proceed*.

    Look for, at the beginning of
  • What Whammo [perl.org] said, and from perlop:

    In scalar context, each execution of "m//g" finds the next match, returning true if it matches, and false if there is no further match. The position after the last match can be read or set using the pos() function; see the pos entry in the perlfunc manpage. A failed match normally resets the search position to the beginning of the string, but you can avoid that by adding the "/c" modifier (e.g. "m//gc"). Modifying the target string also resets the search position.