while (my $rule = chomp() { my $sentences = $pairs{$rule}; # Do what you want with the data returned }