in reply to Hash Key vs. Quantifier Ambiguity in Regex Context
(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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Hash Key vs. Quantifier Ambiguity in Regex Context
by QM (Parson) on Apr 01, 2004 at 00:24 UTC |