insensate has asked for the wisdom of the Perl Monks concerning the following question:
Twice, in following code I test for the presence of a key in this hash. I notice that the second time i perform the test, the script always observes the key exists. I am wondering if I am inadvertently defining a key in my first check? The check follows...It is identical each time performed:while(<DATA>){ ($key,$value)=split; push(@$myhash{$key}},$value); }
Does this inadvertently define a key? If so, is there an easier, more accurate way?if($myhash{$key)){ do something... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Presence of Key in Hash of Arrays
by dpuu (Chaplain) on Aug 02, 2002 at 20:14 UTC | |
|
Re: Presence of Key in Hash of Arrays
by DamnDirtyApe (Curate) on Aug 02, 2002 at 20:41 UTC | |
|
Re: Presence of Key in Hash of Arrays
by insensate (Hermit) on Aug 02, 2002 at 20:12 UTC | |
|
Re: Presence of Key in Hash of Arrays
by tosh (Scribe) on Aug 02, 2002 at 22:31 UTC |