Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: using variables in regular expr replace

by Eimi Metamorphoumai (Deacon)
on Dec 02, 2004 at 17:53 UTC ( #411884=note: print w/replies, xml ) Need Help??

in reply to using variables in regular expr replace

Use \Q and \E
$line =~ s/\Q$var2\E/$var1/;
(In this case you don't need the \E at the end, since it'll end at the end of the regexp anyway, but it's good to know if you do need it later.)

Also, I'm not sure what you mean by "I can't use ' instead of " because of algorytm specific", but if you need to interpolate variables and still not have to quote quotes.

my $line = <<"HTML"; <a href="/{HOST}?action">123</a>:</b><br>[img-smile "58-41" ":)"] HTML chomp $line;
Or you can use qq with just about any delimiter.
my $line = qq#<a href="/{HOST}?action">123</a>:</b><br>[img-smile "58- +41" ":)"]#;

Replies are listed 'Best First'.
Re^2: using variables in regular expr replace
by b888 (Beadle) on Dec 02, 2004 at 18:05 UTC
    Thanks to all

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://411884]
[Corion]: Heh. After a bit of hacking, the Pg parser now "just" fails because some Win32 functions of Postgres aren't included in the lib I'm hacking up. Progress, I guess :)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2018-03-23 21:10 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (296 votes). Check out past polls.