On Tue, Oct 21, 2008 at 6:51 PM, Ben Scott <[EMAIL PROTECTED]> wrote:
> Challenge accepted.... okay, intersect.pl will follow in a separate message.
#!/usr/bin/perl -w
# intersect.pl
# Gives the intersection of two text files (lines contained in both files).
# Similar to comm(1), but does not require sorted input.
# Specify input files as command arguments.
# Provided free of charge, without restriction on use, modification, or
# redistribution. No warranty. Use at your own risk.
use strict;
use warnings FATAL=>'all';
use Fatal qw (open close);
use constant PRESENT => 1;
my (%one, %two);
open FH, "<$ARGV[0]";
$one{$_} = PRESENT while (<FH>);
close FH;
open FH, "<$ARGV[1]";
$two{$_} = PRESENT while (<FH>);
close FH;
foreach my $one (keys %one) {
if (defined $two{$one}) {
print $one;
}
}
# EOF intersect.pl
_______________________________________________
gnhlug-discuss mailing list
[email protected]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/