in reply to comparing lines in two files
As per our conversation in the CB,
use strict; use warnings; open(my $sav_fh, '<', 'saved_system.txt' ) or die; open(my $cur_fh, '<', 'current_system.txt') or die; my @sav_files = sort <$sav_fh>; my @cur_files = sort <$cur_fh>; my @rem_files; my @new_files; while (@sav_files && @cur_files) { if ($sav_files[0] lt $cur_file[0]) { push @rem_files, shift(@sav_files); } elsif ($sav_files[0] gt $cur_file[0]) { push @new_files, shift(@cur_files); } else { shift @sav_files; shift @cur_files; } } push @rem_files, @sav_files; push @new_files, @cur_files; open(my $rem_fh, '>', 'removed.txt') or die; print $rem_fh @rem_files;
|
|---|