Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by trizen (Hermit)
on Feb 01, 2013 at 17:06 UTC ( #1016589=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; 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*', $_}; }
  • Comment on Re: Compare two txt files and print the difference between the two files.
  • Download Code

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
    Great script! Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016589]
help
Chatterbox?
LanX LOLs
[perldigious]: If you want a linguistic adventure...
[perldigious]: No offense to any Scotsman, I love Scots. Well actually, I love Scotch, but I'm sure the people are great too. :-P
[Discipulus]: perldigious i understand i word on ten, to be optimistic..
LanX will try to give his next LPW talk with a Cogney intonation
[Discipulus]: if you love Scotch in scotland your safety will be.. glengranted
[LanX]: *Cockney

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-06-23 16:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (552 votes). Check out past polls.