Another way of writing it:my $var = {'one', 'two', 'red', 'blue'}->{'fish'};
Since the anonymous hash doesn't have a key named fish, you get undef when using fish as a hash subscript. I'm having trouble seeing the parallel between the example hash and the "real world" hash you present...my %hash = (one => 'two', red => 'blue'); my $hash_ref = \%hash; my $var = $hash_ref->{fish};
Do you want to search the hash based on some inner structure? You can only fetch things based on the key, not what's in the value, as that's what hashes are for. You'll have to make some sort of reverse-lookup hash to fetch things by the ext array.
Update: I get it now, but I still don't think the code you had should raise an error. It's a hash dereference of a valid hash.
blokhead
In reply to Re: strict and warnings but no error?
by blokhead
in thread strict and warnings but no error?
by cLive ;-)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |