
Paul
Enthusiast
Jul 23, 2002, 4:44 PM
Post #4 of 5
(2969 views)
|
Re: [jryan] Difficult problem...
[In reply to]
|
Can't Post
|
|
>> You need to use exists instead of defined. Defined works on the variable itself; since %file1hash has elements, it will always be defined. Exists checks for the existence of a key within the hash, which is what you want. << defined in the context used above checks whether the hash value is "defined", exists checks whether the hash key "exists". >> since %file1hash has elements, it will always be defined << No it won't. Consider: $hash{Test1} = 1; $hash{Test2} = undef; print defined $hash{Test2} ? 1 : 0; That will print 0 as the Test2 key has an undefined value, yet %hash still has "elements".
(This post was edited by RedRum on Jul 23, 2002, 4:45 PM)
|