Friday, 16 May 2014

Extracting pattern + from results + perl

Extract Pattern:

MPDE2
./lost+found/sun10_x86.x.70824b20ac1c11de94390002c45ed04c@@/main/0
MPDE2
./bscs/batch/config/README.mpde2@@/main/1
./bscs/batch/config/install.sh@@/main/1
./bscs/batch/config/make.aix4@@/main/1
BATCH
./bscs/batch/bscs.passwd@@/main/1
./bscs/batch/install.txt@@/main/1
./bscs/batch/readme@@/main/1
BATCH
./bscs/batch/build.xml@@/main/1
./bscs/batch/src/bchs/ChargeItem.cpp@@/main/10
./bscs/batch/src/bchs/ChargeItem.hpp@@/main/4
./bscs/batch/src/bchs/DocHeader.cpp@@/main/15
./bscs/batch/src/bchs/DocHeader.hpp@@/main/3
./bscs/batch/src/bchs/UdrLocalDefines.hpp@@/main/2
./bscs/batch/src/bghs/UdrParser.cpp@@/main/10
./bscs/batch/src/bghs/UdrParser.hpp@@/main/7
BATCH
./blueprint/performance/perfclient/input/activateContract.xml@@/main/1
./blueprint/performance/perfclient/input/activateCustomer.xml@@/main/1
./blueprint/performance/perfclient/input/activatePrepaid.xml@@/main/1
./blueprint/performance/perfclient/input/billcycles.txt@@/main/1



Script:


use warnings;
$comp=uc($ARGV[0]);

open("FILE","output2.txt");
@line=<FILE>;
$d=0;
$e=0;
for($i=0;$i<@line;$i++)
{
        chomp($line[$i]);
        if($line[$i]=~/^$comp/)
        {
        $d=$d+1;
        $e=1;
        }
        if($d == 1)
        {
        print $line[$i]."\n";
        }
        $d=0 if($d > 1);
        exit if(($e == 1)&&($line[$i] !~ /^$comp/)&&($line[$i] =~ /^[A-Z]+/));
}







No comments:

Post a Comment