in reply to Re^2: restricting values to a nested datastructure
in thread restricting values to a nested datastructure
I prefer the arrow notation instead of $a{abd}[0]#!/usr/bin/perl -w use strict; use Data::Dumper; my %a; if ( exists $a{'abd'} and defined $a{'abd'}->[0] ) { print "yes\n"} print Dumper \%a; __END__ Prints: $VAR1 = {};
However,
Update: not the same! forgot about 0, zero, Ooops
is the same.
Whether each term doesn't "exist" or is not "defined" has the same true/false meaning. To prevent the autovivification, each "level" of the hash has to be tested, starting from the first. As long as that is done, it doesn't matter whether 'exists' or 'defined' is tested for subsequent levels.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: restricting values to a nested datastructure
by zwon (Abbot) on Dec 15, 2011 at 02:21 UTC |