whitebread

12.10.2004

Thank you perl

A poor man’s sql select for two files that I wrote today:


#!/usr/bin/perl

%fileone = ( );
%filetwo = ( );
open(FIRST, "< $ARGV[0]") || die "Could not open $ARGV[0]";
open(SECOND, "<$ARGV[1]") || die "Could not open $ARGV[1]";
while(< FIRST >) {
    $line = uc($_);
    $fileone{”$line”} = 1;
}
close(FIRST);
open (OUT, “>in_both”);
while(< SECOND >) {
    $line = uc($_);
    if($fileone{”$line”} == 1) {
        print OUT “$_”;
    }
}
close(SECOND);
close(OUT);
exit;

Comments are closed.

 

The views and opinions expressed in this page are strictly those of the page author.
The contents of this page have not been reviewed or approved by the University of Minnesota.