in reply to Re^2: compare most recent file with second most recent file and output difference
in thread compare most recent file with second most recent file and output difference

Hi, jjoseph8008

I'm not sure what's causing the problem within File::Slurp, so please try the following which doesn't use that Module:

use strict; use warnings; my ( %file1Hash, %file2Hash, %mergedHash ); my @files = sort { -M $a <=> -M $b } <"*.txt">; do { chomp; $file1Hash{$_}++ } for getFileLines($files[0]); $mergedHash{$_}++ for keys %file1Hash; do { chomp; $file2Hash{$_}++ } for getFileLines($files[1]); $mergedHash{$_}++ for keys %file2Hash; print "$_\n" for grep $mergedHash{$_} == 1, keys %mergedHash; sub getFileLines { open my $fh, '<', $_[0] or die $!; return <$fh>; }
  • Comment on Re^3: compare most recent file with second most recent file and output difference
  • Download Code