I'm still experimenting with the HoA from a couple of days ago. I just
realized there is the possibility for having duplicate elements of the
array. How do I prevent that?
Thanks,
Mike
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper::Simple;
my %HoA;
while (my $line = <DATA>){
chomp $line;
my ($prod, $flavor) = split ' ', $line, 2;
push @{ $HoA{ $prod } }, $flavor;
}
for my $i ( keys %HoA ) {
print "$i -- @{ $HoA{$i} }\n";
}
warn Dumper (\%HoA);
__DATA__
jelly strawberry
jelly apple
jelly pear
jelly grape
jelly pear
jam strawberry
jam apple
jam apple
jam grape
milk plain
milk chocolate
milk strawberry
--
If I had it all to do over again, I'd spell creat with an "e". -
Kernighan
20:15:01 up 14 days, 17:06, 0 users, load average: 0.09, 0.29, 0.25
Linux Registered User #241685 http://counter.li.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/