Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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?
[holli]: but really, there are a lot of myths around wine. starting with people thinking they could distinguish red and white wine by taste (when blindfolded) let alone australian and french red win
[holli]: that's an empirical fact btw
[Corion]: holli: Well, there are whites and reds that you can distinguish, as some of the red wines have more tannine which makes the wine taste bitter rather than sour ;)
[Corion]: But other than that, don't judge wines on price, and if you don't like the taste you don't have to drink the wine ;-D

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2017-09-25 13:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (280 votes). Check out past polls.

    Notices?