Skip to content

Instantly share code, notes, and snippets.

@riywo
Created February 4, 2011 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riywo/810800 to your computer and use it in GitHub Desktop.
Save riywo/810800 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
exit if(@ARGV != 2);
my $file1 = $ARGV[0];
my $file2 = $ARGV[1];
my %data1;
open FH, "<$file1";
while (my $line = <FH>){
chomp $line;
$data1{$line} = 1;
}
close FH;
my %data2;
open FH, "<$file2";
while (my $line = <FH>){
chomp $line;
if ($data1{$line}){
delete $data1{$line};
}else{
$data2{$line} = 1;
}
}
close FH;
print "######## file1 only ##########\n";
print "$_\n" for(sort keys %data1);
print "\n######## file2 only ##########\n";
print "$_\n" for(sort keys %data2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment