Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by trizen (Friar)
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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-12-18 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (41 votes), past polls