while() { chomp; my $line=$_; $SubsCount++; my $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; #ix0:S13("OptInState:3G")ix1:S11("CircleId:MH")ix2:S8("DevType:")ix3:S9("imei:NULL")ix4:S16("PlanType:prepaid") #print $opcinfo,"\n"; 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; #groups:A1[ix0:S10("3BASIC:100")] if($line=~/groups:A(\d+)\[(.*?)\]/) { my $plans=$2; my @AllPlans = split('ix\d+:S\d+\("',$plans); #print Dumper($AccUsg->{$msisdn}); foreach my $p ( @AllPlans ) { $p =~ s/\"\)//g; if ($p eq "" ) { next; } #my @planname=split(":",$p); if ( $p =~ /(\w+):(\d+)[:]?(.*)/) { my $planname=$1; my $priority=$2; my $expdate=$3; $expdate =~ s/,/\;/g; if( exists ( $AccUsg->{$msisdn}->{$planname} ) ) { if ( $expdate eq "") { push(@ValidPlan,"$planname;$priority;;;$AccUsg->{$msisdn}->{$planname}"); } elsif ( length($expdate) > 19 ) { push(@ValidPlan,"$planname;$priority;$expdate;$AccUsg->{$msisdn}->{$planname}"); } else { push(@ValidPlan,"$planname;$priority;$expdate;;$AccUsg->{$msisdn}->{$planname}"); } } else { if( $expdate eq "") { push(@ValidPlan,"$planname;$priority;;;"); } else { if( length($expdate) > 19 ) { push(@ValidPlan,"$planname;$priority;$expdate;"); } else { push(@ValidPlan,"$planname;$priority;$expdate;;"); } } } } } } if ( $line=~/familyId:S(\d+)\(\"(.*?)\"\)/ ) { $familyId=$2; } if ( $line=~/trafficIds:A(\d+)\[(.*?)\]/ ) { $trafficIds=$2; } #Now sorting the printplans priority wise # my $printPlan=join("|",@ValidPlan); my @validPlanSorted = sort { ($b =~ /(.*?);(\d+);(.*?)/)[1] <=> ($a =~ /(.*?);(\d+);(.*?)/)[1] } @ValidPlan; my $printPlan=join("|",@validPlanSorted); $finalCount++; #print OUT "$msisdn;$IMEI;$Circle;$DeviceType;$OPTIN;$PlanType;$familyId;$trafficIds;$printPlan\n"; print OUT "$msisdn,$IMEI,$Circle,$DeviceType,$OPTIN,$PlanType,$printPlan\n"; } close(FH);