in reply to Re: Re: Re: Can PERL know a line without matching?
in thread Can PERL know a line without matching?
Now for the scriptmSOriginatingSMSinSMSIWMSC Call Identification Number: 10275084 Record Sequence Number: 2205369 Exchange Identity: MAPP01E 0117802 MSC Identification: TON: 1 NPI: 1 MSISDN: 19207079800 Calling Party Number: TON: 1 NPI: 1 MSISDN: 19207029659 Date for Start of Charge: 01/07/18 Time for Start of Charge: 00:14:33 Traffic Activity Code: TeleService Code: x'22 Service Centre Address: TON: 1 NPI: 1 MSISDN: 14147139800 Charged Party: 0 Miscellaneous Information: NULL MSTerminating Call Identification Number: 10275019 Related Call Number: 10275004 Record Sequence Number: 2205370 Exchange Identity: MAPP01E 0117802 MSC Identification: TON: 1 NPI: 1 MSISDN: 19207079800 Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'4F07 Incoming Route: MAD01TI Outgoing Route: BAPL01O Calling Party Number: TON: 4 NPI: 1 MSISDN: 6082572086 Called Party Number: TON: 1 NPI: 1 MSISDN: 16084466501 IMSI: 310640010049547 IMEI: NULL Mobile Station Roaming Number: TON: 1 NPI: 1 MSISDN: 16084469974 Redirecting Number: NULL Redirection Counter: 0 Original Called Number: NULL Date for Start of Charge: 01/07/18 Time for Start of Charge: 00:14:33 Chargeable Duration: 00:00:00 Traffic Activity Code: *020 TeleService Code: x'11 Bearer Service Code: NULL Internal Cause and Loc: LOCATION: 2 CAUSE: 61 Time from Register Seizure to Start of Charging: 00:00:18 Time for Stop of Charging: 00:14:33 Interruption Time: 00:00:00 Type of Calling Subscriber: 1 Disconnecting Party: 2 Charged Party: 1 Fault Code: NULL eosInfo: x'0 Call Position: 2 Miscellaneous Information: NULL Restart During Call: NULL Restart Between Disc and Output: NULL Origin for Charging: x'1 Cell ID for Last Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'4F1D Location Number: TON: 1 NPI: 1 MSISDN: 14147089800 Output for Subscriber: NULL Last Partial Output: NULL Partial Output Rec Num: NULL Regional Service Used: NULL Region Dependent Charging Origin: NULL Transparency Indicator: NULL dTMFUsed: NULL Tariff Class: x'A Tariff Switch Indicator: 0 SS Code: NULL ICI Ordered: NULL
As you can see from the script what I'm trying to do is have the Title of the record block and the lines I specifiy per block to print only if the script finds the $msisdn in any of the blocks. That's the phone number or 10th line #11th if you count Title "MSTerminating" as line 1 for a block. At the end the number is 6082572086. So for example since that is the number I'm interested in, the only record block which contains the number I'm searching for is "MSTerminating" and not any of the other record blocks so I'd want it to print off only the lines for "MSTerminating" as that is the only place the number was found.#!/usr/bin/perl chomp($msisdn = <STDIN>); $/ = ""; # read paragraphs while ($para = <>) { $lastHeading; @lines = split(/\n/, $para); if (@lines == 1) # A Heading { $lastHeading = $lines[0]; next; } my $hitMe; if ($msisdn && $lastHeading eq "MSTerminating") { #if ($lastHeading eq "MSTerminating") { print $lines[13]; # twelth line print $lines[2]; # third line print $lines[5]; # sixth line print $lines[4]; # fifth line } elsif ($lastHeading eq "MSORIGINATING") { $hitMe = $lines[5]; # sixth line } elsif ($lastHeading eq "mSOriginatingSMSinSMSIWMSC") { print $lines[5]; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Can PERL know a line without matching?
by da (Friar) on Jul 30, 2001 at 23:57 UTC |