Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Re: Re: look-behind regex

by I0 (Priest)
on Jul 25, 2002 at 14:51 UTC ( #185212=note: print w/replies, xml ) Need Help??

in reply to Re: Re: look-behind regex
in thread look-behind regex

How about s/(toto)|foo/$1||'bar'/e

Replies are listed 'Best First'.
Re: Re: Re: Re: look-behind regex
by Anonymous Monk on Jul 25, 2002 at 15:18 UTC

    But the reason I used defined() was that I wanted to give a general solution. Someone might copy the code and change toto to something else that matches something that is false without reflecting on how it works. Or you might change it yourself later. Then you perhaps abstract the pattern, and suddenly you have a hard-to-trace bug. I always try to code so that I don't bite myself later on when I patch my code.

      In this case, it's easy enough to ensure that $1 is not false. Even if zejames had wanted 'foo' not preceeded by '0' you could substitute  s/(0.*foo)|foo/($1,'bar')[!$1]/es

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://185212]
[Lady_Aleena]: Hello. Why is this dying at -exec: my @music_times = qx(find ~/Music/Albums/ -type f -iname '*.mp3' -exec {} \;); with the error find: missing argument to `-exec'
[Lady_Aleena]: ACK! my @music_times = qx(find ~/Music/Albums/ -type f -iname '*.mp3' -exec mp3info -p "%S\n" {} \;);
[marioroy]: :)
marioroy adds oatmeal cookies to the platter on the sideboard.
marioroy adds oatmeal raisin cookies to the platter on the sideboard.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-04-23 09:10 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (430 votes). Check out past polls.