01 June 2006

Intersection of Contents in Two Files

#!/usr/bin/perl
#/*Author : ~rAGU (ragu dot ks at gmail dot com) */
#/*Descripation: A script to find the intersection set of the lines in two text files */
#/* when one of the file is a subset of the other */
#/* finsec.pl */

open (SET, @ARGV[0]);
$isInSubset = 0;
$count = 0;

while ($lineInSet = ) {
chop($lineInSet);
#$lineInSet =~ s/^\s*(.*?)\s*$/$1/;
$count++;
$counts = 0;
open (SUBSET, @ARGV[1]);

while ($lineInSubset = ) {
$counts++;
chop($lineInSubset);
#$lineInSubset =~ s/^\s*(.*?)\s*$/$1/;

if ($lineInSet eq $lineInSubset) {
$isInSubset = 1;
}

} #End subset loop

close (SUBSET);
if ($isInSubset == 0){
#chop($lineInSet);
print "$lineInSet";
}
$isInSubset =0;

} #End of set loop

close (SET);

#/* End of the program */

3 comments:

  1. Anonymous8:44 am

    Great site lots of usefull infomation here.
    »

    ReplyDelete
  2. Anonymous12:06 pm

    I really enjoyed looking at your site, I found it very helpful indeed, keep up the good work.
    »

    ReplyDelete
  3. Anonymous4:02 pm

    Hey what a great site keep up the work its excellent.
    »

    ReplyDelete

Please leave a note about what you think about this write up. Thanks.