in reply to RE: Re: Populating a Hash: Can someone help me to understand?
in thread Populating a Hash: Can someone help me to understand?
Now, when I uncomment the foreach/print block, it prints as intended. However, when I add:my @array = subroutine($file1, $list1); #foreach my $item(@array) { #print "$item\n"; # }
the program returns only one value per key, while @values contains several whitespace delimited elements.my %hash; while (@keys and @values) { $hash{shift @keys} = shift @values; } foreach my $k (sort keys %hash) { print "$k => $hash{$k}\n"; }
|
---|