Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: substitution question

by jkahn (Friar)
on Oct 17, 2002 at 18:20 UTC ( #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";


Comment on Re: substitution question
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2014-12-26 18:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (174 votes), past polls