Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2017-10-20 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (264 votes). Check out past polls.

    Notices?