Perl Script to find intersection of lines in two files
#!/usr/bin/perl
#/* Author : ~rAGU () */
# /*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 */
# 2004
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 */
#/* Author : ~rAGU () */
# /*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 */
# 2004
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 */
Comments