PDA

Click to See Complete Forum and Search --> : Getting data from compressed files ...


blackeyed
Jul 14th, 2005, 05:01 PM
I have one piece of code written in Perl that extracts certain text from list of files and redirect that line to one output file. But the problem is that it does not work with compressed files. Pls help me out how to run it on compressed files.



# Program in Perl
# Purpose : To fetch customer of international numbers ie rahul international data.
# output : /u/batch/tested/testing.out
$counter=0;
$counter1=0;
$counter2=0;
$var=0;
chomp($intake = $ARGV[0]);
$path_ascii="/user2/ascii/$intake";
print "$path_ascii";
system("pwd");
open(FW,">/home/user/download/deepak/output/post.out");
open(MW,">/home/user/download/deepak/output/777_888_886.txt");
opendir(DIR,"$path_ascii");
while ($file = readdir(DIR))
{
if ($file =~ /$intake/)
{
open (RR,"$path_ascii/$file");
while ( $line = <RR> )
{
if ( $line =~ /18001/ or
$line =~ /1800977/ or
$line =~ /1800966/ or
$line =~ /180043/ or
$line =~ /180044/ or
$line =~ /180088/ or
$line =~ /180033/ or
$line =~ /1800852/ or
$line =~ /1800965/ or
$line =~ /1800961/ or
$line =~ /1800218/ or
$line =~ /180047/ or
$line =~ /180065/ or
$line =~ /180082/ or
$line =~ /180094/ or
$line =~ /180066/ or
$line =~ /180092/ or
$line =~ /180032/ or
$line =~ /180049/ or
$line =~ /180031/ or
$line =~ /175704865/ or
substr($line,138,4) eq "1800"

)
{
print FW qq | $line | ;
}


if ($line =~ /18777F/ )
{
$counter=$counter+1;
}

if ( $line =~ /18888F/ )
{
$counter1=$counter1+1;
}
if ( $line =~ /18886F/ )
{
$counter2=$counter2+1;
}

}
}

}

print MW qq |\n Data for the month of $out_dir |;
print MW qq |\n Value of 777 is $counter |;
print MW qq |\n Value of 888 is $counter1 |;
print MW qq |\n Value of 886 is $counter2 |;

print "Please collect your output file in /dbs0/scripts/testing.out";

sub trim1()
{

$_= shift;
while(s/^ //g){}
while(s/ $//g){}
return($_);
}