in reply to Compare two txt files and print the difference between the two files.
use strict; use warnings; my $first_file = shift || 'a.txt'; my $second_file = shift || 'b.txt'; open my $a_fh, '<', $first_file or die "$first_file: $!"; open my $b_fh, '<', $second_file or die "$second_file: $!"; my %second_file; @second_file{map { unpack 'A*', $_ } <$b_fh>} = (); while (<$a_fh>) { print unless exists $second_file{unpack 'A*', $_}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Compare two txt files and print the difference between the two files.
by Anonymous Monk on Apr 05, 2017 at 17:45 UTC |