in reply to Substitution with regexes in variables
>perl -wMstrict -le "$_ = 'this is a bad idea'; for my $substitution (@ARGV) { print qq{substitution: $substitution}; my $subs = eval $substitution; if ($@ or not defined $subs) { die qq{$substitution failed: $@}; } print; } " s/this/that/ "s/is/would be/" "s/(a)???/$1 very/" substitution: s/this/that/ that is a bad idea substitution: s/is/would be/ that would be a bad idea substitution: s/(a)???/$1 very/ s/(a)???/$1 very/ failed: Nested quantifiers in regex; marked by <-- HERE in m/(a)??? <-- HERE / at (eval 3) ...
|
|---|