shell, perl, performance, parallelism, profiling,	etc. (was: Upgrade guidance)
    Ben Scott 
    dragonhawk at gmail.com
       
    Tue Oct 21 18:52:59 EDT 2008
    
        - Previous message: shell, perl, performance, parallelism, profiling,	etc. (was: Upgrade guidance)
 
        - Next message: shell, perl, performance, parallelism, profiling,	etc. (was: Upgrade guidance)
 
         -  Messages sorted by: 
              [ date ]
              [ thread ]
              [ subject ]
              [ author ]
         
 
       
    
  
On Tue, Oct 21, 2008 at 6:51 PM, Ben Scott <dragonhawk at gmail.com> 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
    
    
        
	- Previous message: shell, perl, performance, parallelism, profiling,	etc. (was: Upgrade guidance)
 
	- Next message: shell, perl, performance, parallelism, profiling,	etc. (was: Upgrade guidance)
 
         -  Messages sorted by: 
              [ date ]
              [ thread ]
              [ subject ]
              [ author ]
         
 
       
More information about the gnhlug-discuss
mailing list