in reply to Re: check if an element exists in array
in thread check if an element exists in array

You can save yourself some typing as Perl will auto-vivify the anonymous array for you if it doesn't exist already. Your

if (!exists $people{$name}) { $people{$name} = [ $value ]; # store array with one value } else { push @{$people{$name}}, $value; # push 2nd,3rd,.. value on arr +ay }

can become

push @{$people{$name}}, $value;

I hope this is of interest.

Cheers,

JohnGG