#!/usr/bin/perl
use strict;
use warnings;
sub usage {
print "$0: filea fileb\n";
exit -1;
}
usage unless scalar @ARGV == 2;
my $a = shift @ARGV;
my $b = shift @ARGV;
open A, "<$a" or die "can't open $a: $!\n";
open B, "<$b" or die "can't open $b: $!\n";
my %bl;
$bl{$_}++ for (<B>);
for (<A>) {print "$_" unless $bl{$_}};
__END__
Or using map for the last lines:
my %bl = map {$_ => 1 } (<B>);
map {print "$_" unless $bl{$_}} (<A>);
TIMTOWTDI
No comments:
Post a Comment