my %filehash; { open my $fh, '<', '/path/to/file_one.txt' or die $!; $filehash{$_}++ while <$fh>; close $fh or die $!; } { open my $fh, '<', '/path/to/file_two.txt' or die $!; while (<$fh>) { print qq("$_" is not in file one\n) if not exists $filehash{$_}; } }