while ( my $zeile = <$dataFH> ) { exit 0 if $zeile =~ / \b OPTIMAL \b /x; # Ausstieg bei erster Zeile mit OPTIMAL if ( $zeile =~ /$typeRegExp/ ) { my ($phy) = $zeile =~ / \b phy \s+ (\w+) /x; my ($state) = $zeile =~ / \b state \s+ (\w+) /x; my ($flags) = $zeile =~ / \b flags \s+ (\w+) /x; print "phy: $phy, state: $state, flags: $flags\n"; } else { print "UNKNOWN\n"; } }