Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Regular expression "replace string interpolation" problem

by pc88mxer (Vicar)
on May 16, 2008 at 22:21 UTC ( #687035=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    ...
    my $replace = '"$1 Perl"';
    
    $text2 =~ s/$match/$replace/ee;
    
  2. or download this
    my $replace = '$1 Perl'; # use original setting of $replace
    
    $text2 =~ s/$match/'"'.$replace.'"'/ee;
    
  3. or download this
    
    my $replace = sub { "$1 Perl" };
    
    $text2 =~ s/$match/$replace->()/e;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://687035]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-10-01 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (389 votes), past polls