Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Compare two txt files and print the difference between the two files.

by 7stud (Deacon)
on Feb 02, 2013 at 02:33 UTC ( #1016633=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Compare two txt files and print the difference between the two files.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016633]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2015-07-30 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls