in reply to Avoid eval() / dynamic regular expressions
Is there a way to compile the eval only once?
$regex contains something of the form s/.../.../?
You can't have a reference to an op, but you can have a reference to a sub...
my $op = 's/a/A/g'; my $sub = eval "sub { $op }"; $_ = "abbracadabra"; $sub->(); print "$_\n";
AbbrAcAdAbrA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Avoid eval() / dynamic regular expressions
by grasbueschel (Initiate) on Dec 15, 2009 at 08:43 UTC |