http://www.perlmonks.org?node_id=1016633


in reply to Compare two txt files and print the difference between the two files.

use strict; use warnings; use 5.012; my $fname = 'a.txt'; open my $afile, "<", $fname or die "Couldn't open $fname: $!"; my %a_links; while (my $link = <$afile>) { chomp $link; $a_links{$link} = undef; } close $afile; $fname = 'b.txt'; open my $bfile, "<", $fname or die "Couldn't open $fname: $!"; while (my $link = <$bfile>) { chomp $link; next if exists $a_links{$link}; say $link; } close $bfile; --output:-- http://www.ok.com/test_www.pdf http://www.ok.com/test_345.pdf