in reply to Different hashes?
You are overwriteing the key in %AllProducts every loop. You need to make the hash value an array ref then push onto it.
Try this:
Try this:
foreach my $line(@ProductArray) { my ($Category, $ID, $Name, $Type, $Size) = split( / /, $line ); unless(exists $AllProducts{$Category}){ $AllProducts{$Category} = []; } push(@{$AllProducts{$Category}}, $ID, [$Name, $Type, $Size]); print OUTPUT Dumper(\%AllProducts); }
- Tom
|
---|
In Section
Seekers of Perl Wisdom