my %results; open my $fh1, "<", "file1" or die $!; while (my $line = <$fh1>) { chomp $line; $results{ $line } = 1; } open my $fh2, "<", "file2" or die $!; while (my $line = <$fh2>) { chomp $line; my $part = $line; $part =~ s/\..*//; unless ($results{ $part }) { say $line; } }