Ankur_kuls has asked for the wisdom of the Perl Monks concerning the following question:
I have a perl script which uses 2 inputs file of size 16gb & 800mb and creates an output file. It creates 4 hashes to store data from 800mb file and then compare and retrieve data from the other 16gb file and finally creates a report Now its working pretty fine but it is getting stuck at random creating the final report of around 500mb. No Idea why it is getting stuck. It doesn't seem a script bug as the 500mb data of report is generating perfectly. Please help me..not pasting the code here as it is too big to put...please let me know if you need further info. Thanks
:) sorry for the trouble..I am pasting my code here...please help.
#!/usr/bin/perl use Data::Dumper; my $lookup; $lookup; ##Maharashtra to MH & Mumbai to MUM open(FH,"<",$ARGV[0]); open(AH,"<",$ARGV[1]); open(OUT,">",$ARGV[2]); open(LOG,">",$ARGV[3]); my $SubsSize= -s $ARGV[0]; my $AccuSize= -s $ARGV[1]; my $SubsCount=0; my $AccuCount=0; my $finalCount=0; my $AccUsg; my $AccUsg1; my $AccUsg2; my $AccUsg3; while(<AH>) { chomp; my $line=$_; $AccuCount++; my $MobileNumber; if( $line =~ /subscriberId:(\w+)\(\"(\d+)\"\)/ ) { $MobileNumber=$2; } my $plan=$line; $plan =~s/\\//g; my @AccVolume; if ( $plan =~ /usageControlAccum:(\w+)\(\"(.*)\"\)/ ) { my $p=$2; $p=~s/:\{/ => {/g; $p=~s/:\[/ => [/g; $p=~s/\"/\'/g; $p=~s/\':/\'=>/g; $p=~s/\}n/\}/g; #print $p,"\n"; my $e=eval($p); if ( @$ ) { push (@AccVolume,"error"); } else { foreach my $value ( @{$e->{'reportingGroups'}} ) { if ( exists ( $value->{'absoluteAccumulated'}->{'counters' +} ) ) { $AccUsg->{$MobileNumber}->{$value->{'subscriberGroupName +'}}=$value->{'absoluteAccumulated'}->{'counters'}->[0]->{'bidirVolume +'}; $AccUsg1->{$MobileNumber}->{$value->{'subscriberGroupNam +e'}}=$value->{'absoluteAccumulated'}->{'counters'}->[0]->{'name'}; $AccUsg2->{$MobileNumber}->{$value->{'subscriberGroupName +'}}=$value->{'absoluteAccumulated'}->{'expiryDate'}->{'volume'}; $AccUsg3->{$MobileNumber}->{$value->{'subscriberGroupNam +e'}}->{'time'}=$value->{'absoluteAccumulated'}->{'previousExpiryDate' +}->{'time'}; $AccUsg3->{$MobileNumber}->{$value->{'subscriberGroupNam +e'}}->{'volume'}=$value->{'absoluteAccumulated'}->{'previousExpiryDat +e'}->{'volume'}; } elsif ( exists ( $value->{'absoluteAccumulated'}->{ +'bidirVolume'} ) ) { $AccUsg->{$MobileNumber}->{$value->{'subscriberGroupName +'}}=$value->{'absoluteAccumulated'}->{'bidirVolume'}; } } } } } close(AH); print OUT "MSISDN,IMEI,Circle,DeviceType,OPTIN,PlanType,counterName,ex +pdate,prevTime,prevVol,PACKID1;priority;startdate;enddate;AccumulateU +sage|PACKID2;priority;startdate;enddate;AccumulateUsage|PACKID3;prior +ity;startdate;enddate;AccumulateUsage|PACKID4;priority;startdate;endd +ate;AccumulateUsage|\n"; while(<FH>) { chomp; my $line=$_; $SubsCount++; $msisdn; my $IMEI; my $Circle; my $DeviceType; my $OPTIN; my $PlanType; my $familyId; my $trafficIds; if($line=~/userId:S(\d+)\(\"(\w+)\"\)/) { $msisdn = $2; } if ( $line=~/operatorInfo:A(\d+)\[(.*?)\]/ ) { my $opcinfo=$2; if( $opcinfo =~ /ix(\d+):S(\d+)\(\"imei:(\w*)\"\)/ ) { $IMEI=$3; } if( $opcinfo =~ /ix(\d+):S(\d+)\(\"OptInState:(\w*)\"\)/ ) { $OPTIN=$3; } if( $opcinfo =~ /ix(\d+):S(\d+)\(\"CircleId:(\w*)\"\)/ ) { $Circle=$3; if( exists ( $lookup->{$Circle} ) ) { $Circle=$lookup->{$Circle}; } } if( $opcinfo =~ /ix(\d+):S(\d+)\(\"DevType:(\w*)\"\)/ ) { $DeviceType=$3; } if( $opcinfo =~ /ix(\d+):S(\d+)\(\"PlanType:(\w*)\"\)/ ) { $PlanType=$3; } } my @ValidPlan; if($line=~/groups:A(\d+)\[(.*?)\]/) { my $plans=$2; my @AllPlans = split('ix\d+:S\d+\("',$plans); foreach my $p ( @AllPlans ) { $p =~ s/\"\)//g; if ($p eq "" ) { next; } if ( $p =~ /(\w+):(\d+)[:]?(.*)/) { $planname=$1; my $priority=$2; my $expdate=$3; $expdate =~ s/,/\;/g; if( exists ( $AccUsg->{$msisdn}->{$planname} ) ) { if ( $expdate eq "") { push(@ValidPlan,"$planname;$priority;;;$AccUsg->{$m +sisdn}->{$planname}"); } elsif ( length($expdate) > 19 ) { push(@ValidPlan,"$planname;$priority;$expdate;$AccU +sg->{$msisdn}->{$planname}"); } else { push(@ValidPlan,"$planname;$priority;$expdate;;$Ac +cUsg->{$msisdn}->{$planname}"); } } else { if( $expdate eq "") { push(@ValidPlan,"$planname;$priority;;;"); } else { if( length($expdate) > 19 ) { push(@ValidPlan,"$planname;$priority;$ex +pdate;"); } else { push(@ValidPlan,"$planname;$priority +;$expdate;;"); } } } } } } if ( $line=~/familyId:S(\d+)\(\"(.*?)\"\)/ ) { $familyId=$2; } if ( $line=~/trafficIds:A(\d+)\[(.*?)\]/ ) { $trafficIds=$2; } my @y = sort { ($b =~ /(.*?);(\d+);(.*?)/)[1] <=> ($a =~ /(.*?);(\d+); +(.*?)/)[1] } @ValidPlan; #ankur my $printPlan=join("|",@y); $finalCount++; print OUT "$msisdn,$IMEI,$Circle,$DeviceType,$OPTIN,$PlanType,$AccUs +g1->{$msisdn}->{$planname},$AccUsg2->{$msisdn}->{$planname},$AccUsg3- +>{$msisdn}->{$planname}->{'time'},$AccUsg3->{$msisdn}->{$planname}->{ +'volume'},$printPlan\n"; close(FH); close(OUT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl script is getting stuck for no reason
by marto (Cardinal) on Jul 31, 2014 at 10:51 UTC | |
|
Re: Perl script is getting stuck for no reason
by davido (Cardinal) on Jul 31, 2014 at 17:17 UTC | |
|
Re: Perl script is getting stuck for no reason
by AppleFritter (Vicar) on Jul 31, 2014 at 11:12 UTC | |
|
Re: Perl script is getting stuck for no reason
by Discipulus (Canon) on Jul 31, 2014 at 10:57 UTC | |
|
Re: Perl script is getting stuck for no reason (swap)
by tye (Sage) on Jul 31, 2014 at 16:58 UTC | |
|
Re: Perl script is getting stuck for no reason
by zentara (Cardinal) on Jul 31, 2014 at 11:59 UTC | |
|
Re: Perl script is getting stuck for no reason
by salva (Canon) on Jul 31, 2014 at 11:02 UTC | |
|
Post the data
by dolmen (Beadle) on Jul 31, 2014 at 12:18 UTC |