Is it evaluation-order safe to match against a string in a variable and assign the result of that execution into the same variable? Similarly, is matching against a regex capture variable safe? In perl 5 all order of evaluation is undefined and while simple cases "work", I'm not sure whether this is sufficiently simple to not pose a problem.
$_ = q(5 <$> const(PV "{key}") s ->6\n); /^(.*?<.> )([\w-]+|\S+)(.*?)$/ or next # $1 == 19 # $2 eq "const" # $3 eq '(PV "{key}") s ->6\n' # Matching against $3 my $pv = ( $3 =~ /[INP]V ("?(?:\\"|[^"])*"?)/ )[0]; # Or matching against a variable and then assigning into it. my $pv = $3; $pv = ( $pv =~ /[INP]V ("?(?:\\"|[^"])*"?)/ )[0];
In reply to Matching and order of evaluation by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |