Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Massive regexp search and replace

by rdfield (Priest)
on Feb 10, 2005 at 15:51 UTC ( #429784=note: print w/replies, xml ) Need Help??

in reply to Massive regexp search and replace

Maybe I'm missing something completely obvious, but have you tried the "o" modifier in your regexes? eg
$INline =~ s/$Source/$Target/egoe


Replies are listed 'Best First'.
Re^2: Massive regexp search and replace
by holli (Monsignor) on Feb 10, 2005 at 16:43 UTC
    You´re missing that the /o-modifier is just a "promise" to perl, that the variable that contains the regex won´t change within the iteration/loop. In this cause using /o is just wrong, because only the first regex would be applied over and over. Regardless of the change of $Source or $Target.

    qr//-ing the regex is something different. When you qr// a string and assign it to a variable you store the compiled regex in it. This is easily proven by ref()-ing that variable, it will return "Regexp". Of course you can store such a Regexp in whatever data-structure you want, not just plain scalars.

    But that is of little use in this case, because there is no qs//-statment (qr// is just for matching, not for replacing).

    holli, /regexed monk/
Re^2: Massive regexp search and replace
by albert.llorens (Initiate) on Feb 10, 2005 at 16:04 UTC
    No, but I have tried precompiling $Source with qr// in my patterns list before I do the actual replacement. Isn't that more or less equivalent to using /o?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://429784]
[LanX]: still can't believe this, must h have been a misunderstanding
[choroba]: fortunately, I haven't the need to verify this
[choroba]: haven't had
[choroba]: but most tourist here are form the US, France, and Russia
[Your Mother]: The best whiskey in Thailand is Vietnamese, is all I know.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2017-02-26 04:58 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (371 votes). Check out past polls.