use strict; use diagnostics; my %hash = ('Abend' => 'NN', 'Sonne' => 'NN', 'Haus' => 'NN', 'Abendsonne' => 'NN'); foreach my $element (sort keys %hash) { if ($element =~ /^$element.+/) { print $element . "\n"; } }