Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How do I change substitution options within a program?

by gaspodethewonderdog (Monk)
on Nov 01, 2006 at 14:58 UTC ( [id://581682]=note: print w/replies, xml ) Need Help??


in reply to How can I change substitution options within a program?

$source = "abc"; $find = "a"; $replace = "x"; $opt = "g"; eval "\$source =~ s/$find/$replace/$opt"; print $source;

Replies are listed 'Best First'.
Re^2: How do I change substitution options within a program?
by ikegami (Patriarch) on Nov 01, 2006 at 17:09 UTC

    Better:

    eval "\$source =~ s/\$find/\$replace/$opt";

    Even better:

    $opt =~ /[^imsx]/ and die(...); eval "\$source =~ s/\$find/\$replace/$opt";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2024-04-23 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found