Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
"be consistent"
 
PerlMonks  

Re: Re: pat match mult/lines mult/pat

by brassmon_k (Sexton)
on Jul 27, 2001 at 19:09 UTC ( #100329=note: print w/ replies, xml ) Need Help??


in reply to Re: pat match mult/lines mult/pat
in thread pat match mult/lines mult/pat

Yes I realized the mistakes I put in my initial entry like not defining the scalars above the array and neglecting array0 and array4 was non-existant.

I've already achieved the results that your idea puts out. I guess my problem is a bit odd to explain.
Those results are:

Calling Party Number: TON: 4 NPI: 1 MSISDN: 6082572086 Calling Party Number: TON: 4 NPI: 1 MSISDN: 6082572086 Charge Number: TON: 3 NPI: 1 MSISDN: 6082572086 Calling Party Number: TON: 4 NPI: 1 MSISDN: 6082572086 Calling Party Number: TON: 4 NPI: 1 MSISDN: 6082572086 Called Party Number: TON: 2 NPI: 1 MSISDN: 16082572086 Called Party Number: TON: 2 NPI: 1 MSISDN: 16082572086
Here's what I did with your idea.
chomp(my $var = <STDIN>); $var = qr($var); $var1 = "MSTerminating" $var2 = "MSORIGINATING" $var3 = "TRANSIT" my $pattern = qr($var1|$var2|$var3); while (<FILE>) { print if /$var/ && /$pattern/; }
Now you see what this bit of code did seemingly match only the $var it's like (and) operator pattern matches are ignored and only one is accepted.

However I did indeed want those lines printed off but I also wanted the record block titles to print. If I do "print if /$vara/" it will do what I want print the record block titles but it will print all of them in the entire document. I only want it to print the section title when it finds the phone number. What I desire is output like the following: So to say it as clearly as I can is if I find the phone number in a record block such as "MSTerminating" or "MSORIGINATING" print the lines I specify like,
line1
line2 etc.
Is there anyway to tell PERL that "MSTerminating" is line1 for a record block and this "Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'4F07" would be line13? Can you tell perl line numbers because I've been looking and that would be ideal for my situation then it would be easy as pie. I could arrange something such as - if you find $var in "MSTerminating" print $line1, $line2, etc. Then the exact results would be there. The only problem is each record block (Like 8 different ones) have a different number of lines and different data in each type of record block. The desired example output is below and I've illustrated the differences with putting (line#) after the text for 3 of the entries as you can see.
MSTerminating Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'4F07 Calling Party Number: TON: 4 NPI: 1 MSISDN: 6082572086 (line15) Called Party Number: TON: 1 NPI: 1 MSISDN: 16084466501 (line16) Date for Start of Charge: 01/07/18 (line18) Time for Start of Charge: 00:14:33 Chargeable Duration: 00:00:00 MSORIGINATING Calling Party Number: TON: 4 NPI: 1 MSISDN: 6082572086 (line10) Called Party Number: TON: 1 NPI: 1 MSISDN: 16084466501 (line11) Date for Start of Charge: 01/07/18 (line30)
Please for the love of lines how do you do accomplish telling PERL this. I've scoured the net and a few books I have to try to figure out how to tell PERL which line to print but all I've found is pattern matching because it's easier. Well unfortuneately I think I need to know how to tell PERL go print line1 then line13 if you find this number under the "MSTerminating" block because that's the only way it can be done in my case I think.

The Brassmon_k
David M. Hagens
Airadigm Communications


Comment on Re: Re: pat match mult/lines mult/pat
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://100329]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-04-21 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls