Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: ignore duplicates and show unique values between 2 text files

by hdb (Prior)
on Apr 29, 2013 at 19:06 UTC ( #1031276=note: print w/replies, xml ) Need Help??


in reply to ignore duplicates and show unique values between 2 text files

If you have TWO files, then you would do "++" on the first, and "--" on the second...

use strict; use warnings; my $file1 = <<FILE1; 261293 'snow > equipment' 261293 'snow > equipment > boots' 261293 'snow > equipment > facemasks' 261293 'snow > equipment > goggles' 261293 'snow > equipment > helmets' 261293 'surf > accessories > books' FILE1 my $file2 = <<FILE2; 261293 'snow > equipment' 261293 'snow > equipment > boots' 261293 'snow > equipment > facemasks' 261293 'snow > equipment > goggles' 261293 'surf > accessories > books' FILE2 my %uniq; $uniq{$_}++ for split /\n/, $file1; $uniq{$_}-- for split /\n/, $file2; print join "\n", grep { $uniq{$_} } keys %uniq; print "\n";

Replies are listed 'Best First'.
Re^2: ignore duplicates and show unique values between 2 text files
by LanX (Chancellor) on Apr 29, 2013 at 19:14 UTC
    > If you have TWO files, then you would do "++" on the first, and "--" on the second...

    this only works if lines are already unique within their files.

    i.a.w. 2-1 is true but means the line appeared in both files...

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031276]
help
Chatterbox?
[Lady_Aleena]: Would someone please derail my train of thought?
[Discipulus]: marto as Marcus Manlius Capitolinus
[Discipulus]: use Dynamite; Lady_Aleena
[Lady_Aleena]: That's the problem. I have 29 scripts, 3 modules, and gads of data I am thinking about deleting out of anger over an API change that made all of those things worthless.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-05-25 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?