in reply to s/// in a sub : passing expressions
Yes, but it is eval, unfortunately. eval is dangerous; Never use it with user input!
Alternatively,s[/][\\/]g for $lhs, $rhs; eval "s/$lhs/$rhs/";
Probably you should reconsider if you really do want this.$rhs =~ s["][\\"]g; $rhs = q["$rhs"]; s/$lhs/eval $rhs/e;
Also, parsing XML with regexes is bad, .* is bad, and $ doesn't do what you think,
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
Perl 6 changes:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: s/// in a sub : passing expressions
by Anonymous Monk on Oct 29, 2005 at 13:39 UTC | |
by Juerd (Abbot) on Oct 30, 2005 at 00:32 UTC | |
by Anonymous Monk on Oct 30, 2005 at 03:10 UTC | |
|
Re^2: s/// in a sub : passing expressions
by ady (Deacon) on Oct 29, 2005 at 13:29 UTC |