in reply to How can I use the value of a scalar as the name of an array variable?

This solution uses a hash of arrays (HoA) instead of symbolic references.
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.

  • Comment on Re: Can I determine if the value of a variable is the same as an arrays name?
  • Download Code