use strict; use warnings; use File::Compare; my %exclude; my $file1 = 'default_sysdumpdev_150319.txt'; my $file2 = 'd100spuptl25e0_sysdumpdev.txt'; my $compare = compare('d100spuptl25e0_sysdumpdev.txt', 'default_sysdumpdev_150319.txt'); open my $file, '<', 'default_sysdumpdev_150319.txt' or die $!; while (<$file>) { chomp; $exclude{$_}++; $file } my $logdatei = 'compare.log'; open my $logfh, '>', $logdatei or die $!; open $file, '<', 'd100spuptl25e0_sysdumpdev.txt' or die $!; while (<$file>) { chomp; if($compare == 1){ print $logfh "False! the files are not equal \n"; print $logfh "$_\n" unless $exclude{$_}; . } elsif($compare == 0){ print $logfh "True! the Files are equal \n"; } } close $logfh;