#!/usr/local/bin/perl eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' if 0; # not running under some shell # # comm # # 1999 M-J. Dominus (mjd-perl-comm@plover.com) # Public domain. # @COL[1,2,3] = (1,1,1); if ($ARGV[0] =~ /^-[123]+$/) { $opt = shift; while ($opt =~ /[123]/g) { $COL[$&] = 0; } } unless (@ARGV == 2) { die "Usage: comm [-123] file1 file2\n"; } open F1, "< $ARGV[0]" or die "comm: Couldn't open file $ARGV[0]: $!\n"; open F2, "< $ARGV[1]" or die "comm: Couldn't open file $ARGV[1]: $!\n"; $r1 = ; $r2 = ; while (defined $r1 && defined $r2) { if ($r1 eq $r2) { print "\t\t", $r1 if $COL[3]; $r1 = ; $r2 = ; } elsif ($r1 gt $r2) { print "\t", $r2 if $COL[2]; $r2 = ; } else { print $r1 if $COL[1]; $r1 = ; } } print $r1 if defined $r1 && $COL[1]; print "\t", $r2 if defined $r2 && $COL[2]; if ($COL[1]) { print while } if ($COL[2]) { print "\t", $_ while }