Tom Christiansen writes:
: >I've very rarely found cases where ?? was useful and // didn't work, and
: >never in regular code.
:
: >From the Camel:
:
: The C<??> operator is most useful when an ordinary pattern match
: would find the last rather than the first occurrence:
:
: open DICT, "/usr/dict/words" or die "Can't open words: $!\n";
: while (<DICT>) {
: $first = $1 if ?(^neur.*)?;
: $last = $1 if /(^neur.*)/;
: }
: print $first,"\n"; # prints "neurad"
: print $last,"\n"; # prints "neurypnology"
:
: Nothing a SMOP can't address, but for one liners at the least, the
: S part would seem to preclude the P part.
I don't think the S and the P are that preclusive. For the example above
you can just say:
/(^neur.*)/ .. ""
If you want to be able to reset, then say
/(^neur.*)/ .. !$x++ # reset with $x = 0;
Larry