use strict; my( @fruit, @meat, @dairy ); my %food; $food{'fruit'} = \@fruit; $food{'meat'} = \@meat; $food{'dairy'} = \@dairy; while (<>) { chomp; my( $category, $item ) = split /\t/; $category = lc $category; # normalize next unless exists $food{$category}; # skip unknown push @{$food{$category}}, $item; } print "Fruits are: @fruit\n";