annotate tools/intersect.pl @ 421:c685b3c5f40b

Update MPD's Makefile.
author Aleksandr Rybalko <ray@ddteam.net>
date Fri, 14 Sep 2012 02:20:50 +0300
parents ae6c0eca3e29
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
1 #!/usr/bin/perl
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
2
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
3 use strict;
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
4
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
5
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
6 my @array1 = @ARGV;
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
7 my @array2 = ();
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
8
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
9 while (<STDIN>)
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
10 {
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
11 chomp;
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
12 push @array2, split(/\s+/);
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
13 }
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
14
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
15
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
16 my @union = my @intersection = my @difference = ();
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
17 my %count = ();
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
18 foreach my $element (@array1, @array2) { $count{$element}++ }
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
19 foreach my $element (keys %count)
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
20 {
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
21 push @union, $element;
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
22 push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element;
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
23 }
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
24
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
25 print "INTESECTION: ".join(" ", @intersection)."\n";
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
26 print "DIFFERENCE: ".join(" ", @difference)."\n";
ae6c0eca3e29 savepoint ports near to our dream
ray@terran.dlink.ua
parents:
diff changeset
27