#!/usr/bin/perl use strict; use warnings; use Tie::File; my $file_one = 'Datei1.txt'; my $file_two = 'Datei2.txt'; open my $fh, '<', $file_one or die $!; tie my @lines, 'Tie::File', $file_two or die $!; while( my $line = <$fh> ){ chomp $line; my @words = $line =~ /\b([A-Z].*?)\b/g; my ($verb) = $line =~ /\b([a-z]+t)\b/; for my $word ( @words ){ unless( check( $word, $verb, @lines ) ){ push @lines, $line; } } } untie @lines; close $fh; sub check{ my ($value) = shift; my ($verb) = shift; for my $line ( @_){ if( $line =~ /\Q$value\E/ and $line =~ /\Q$verb\E/ ){ return 1; } } return; }