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
- Re: Things to remove Dan Sugalski
- Re: Things to remove Martyn J. Pearce
- Re: Things to remove Leon Brocard
- Re: Things to remove Piers Cawley
- Re: Things to remove Bryan C . Warnock
- Re: Things to remove Ted Ashton
- Re: Things to remove Bennett Todd
- Re: Things to remove Hildo Biersma
- Re: Things to remove Russ Allbery
- Re: Things to remove Tom Christiansen
- Re: Things to remove Larry Wall
- Re: Things to remove Bart Lateur
- Re: Things to remove Bryan C . Warnock
- Re: Things to remove Mike Pastore
- Re: Things to remove Casey R. Tweten
- Re: Things to remove Steve Simmons
- Re: Things to remove Nathan Torkington
- Re: Things to remove Damian Conway
- Re: Things to remove Larry Wall
- Re: Things to remove Bart Lateur
- Re: Things to remove Tom Christiansen
