#!/usr/bin/perl # vi:ts=4 sw=4 et: use strict; use warnings; my %hash = ( Abend => 'NN', Sonne => 'NN', Haus => 'NN', Abendsonne => 'NN', ); my $text = q~Haus Abendsonne haussonne hurz~; for my $word ( split /\s+/, $text ) { for my $pre ( keys %hash ) { for my $post ( keys %hash ) { if ( $word =~ /^$pre$post$/i ) { print $word, $/; } } } }