On Thu, Feb 06, 2003 at 10:56:06AM -0500, Joel Gwynn wrote:

> Wow.  This is driving me crazy.  I'm looking for a value in one of the
> keys in a hash, like so:
[...]
> Now, what's driving me crazy is that the two test values are being added
> to the hash, simply by looking for $apples{$t}{weight}.  If I simply
> look for $apples{$t}, like so:
> 
> foreach my $t (@test){ print "$t not found\n" unless $apples{$t} }
> 
> new hash members are not created.  Why should this be?

Uri Guttman wrote an excellent paper on Perl's autovivification:

  http://tlc.perlarchive.com/articles/perl/ug0002.shtml

It includes some sample code to check for hash keys at any
level of a multi-level data structure without triggering
autovivification. (paraphrased from description in article)

-E
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to