(2) You can see that Perl chooses (a) for /$x{1}/. If I want (b), is there a better way than @{[$x{1}]}[0]?
Absolutely. Quote your hash key.
my $x = "(quantifier)"; my %x = ( "1" => "(hash_value)" ); my $z = 'quantifier hash_value'; print "_$1_\n" if $z =~ /$x{'1'}/; # $x{'1'} is hash key __END__ _hash_value_
Hope this helps.
jarich
In reply to Re: Hash Key vs. Quantifier Ambiguity in Regex Context
by jarich
in thread Hash Key vs. Quantifier Ambiguity in Regex Context
by QM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |