use strict; my %food; while (<>) { chomp; my( $category, $item ) = split /\t/; push @{$food{$category}}, $item; } print "Fruits are: @{$food{'fruit'}}\n";