in reply to How can I use the value of a scalar as the name of an array variable?
my %hoa; while (<>) { chomp; my( $category, $item ) = split /\t/; push @{$hoa{$category}}, $item; } for my $cat ( sort keys %hoa ) { print "The following are in category $cat:\n"; for ( @{$hoa{$cat}} ) { print "\t$_\n"; } }
Originally posted as a Categorized Answer.
|
|---|