Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 having an uproarious good time at the Monastery: (14)
As of 2014-11-26 14:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (171 votes), past polls