in reply to Converting a hash element into an array

Hi, You can assing one empty array to each key element and push the values in that array.

like this

my $key = <STDIN>; chomp($key); $hash{$key} = [] unless $hash{$key}; my $val = <STDIN>; chomp($val); push @{$hash{$key}}, $val;

Replies are listed 'Best First'.
Re^2: Converting a hash element into an array
by rockers (Initiate) on Jan 19, 2009 at 12:11 UTC
    @luckypower and @holli:
    Thanks, I was wrong. Declaring it as an array apriori is better.