my @solutions; word: while () { chomp; for my $hint ( keys %hints ) { letters_in_common( $_, $hint ) == $hints{$hint} or next word; } push @solutions, $_; }