Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: substitution question

by jkahn (Friar)
on Oct 17, 2002 at 18:20 UTC ( [id://206085]=note: print w/replies, xml ) Need Help??


in reply to substitution question

Looks like you need to use eval, since you have an executing context.
my $SUBS='s/AA/BB/g'; $STR = "AAXXXAA"; eval "\$STR =~ $SUBS;"; print $STR, "\n";
On the other hand, if you don't like eval:
my $lh_sub = "AA"; my $rh_sub = "BB"; $STR = "AAXXXAA"; $STR =~ s/$lh_sub/$rh_sub/g; print $STR, "\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found