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

I'd use a different kind of data structure: a hash of anonymous arrays. That way, you can just push the new type of food onto the array and look up that array by the hash key, which will be the category of food.

Here's how the data structure looks:

my %foods = ( fruit => [ "apples", "oranges" ], dairy => [ "eggs", "milk" ], meat => [ "sausage", "bacon" ] );
my %foods; while (<DATA>) { chomp; my( $category, $item ) = split /\t/; push @{$foods{$category}} ,$item; } for my $category ( keys %foods ) { print "$category : \n"; for my $item ( @{$foods{$category}} ) { print "\t$item\n"; } print "\n"; }