Great Monks,

First off I never ever matched on multiple lines cuz I never had to. That is a prob for me. I have to go through pages of the text below: I'll describe my prob here and you can look through the text and my proposed solution is below the text. OK first off you see the crazy heading mSOriginatingSMSinSMSIWMSC that is the record block title Then the data for the record. The data I need to have matched are the lines I've enclosed with exclamation marks. Here's how
I need them matched.

What this script is concerned about is multiple Title block names. Lines called "Calling or Called Party" that have a MSISDN or phone number which a person running a search would specify by <STDIN>.

What I need done is relatively simple but I've tried working on this for like 3 days and get jack for results. What I need is for this search to:

Search through the text (When it finds the MSISDN number the user entered on <STDIN> the script needs to print the Record Block title, the Called Party & Calling Party lines, the Charged Party line, the Chargeable Duration line, and the Cell ID line. It gets worse because the same lines aren't in all the Record Blocks and I don't have a clue on how to structure this. So I'd have to say something like this to the script.

Okay if you find the MSISDN that I gave you look and find the record block title (Let's just say 3 types although there are more MSTerminating, MSORIGINATING, TRANSIT) if it is MSTerminating print these lines, if it is MSORIGINATING print these lines, If it is TRANSIT print these lines

Here is the text:
!mSOriginatingSMSinSMSIWMSC! 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
I was thinking if I do something like the below I can get what I want?
print "What msisdn?"; chomp($var = <STDIN>); @patterns = qw($var, $var1, $var2, $var3); $var1 = "MSTerminating" $var2 = "MSORIGINATING" $var3 = "CallForwarding" open(FILE, "output.abbazabba"); while (<FILE>) { foreach $pat (@patterns) { if ( /$pat[1]/ && /$pat[2]/) { print "theselines"; if ( /$pat[1]/ && /$pat[3]/) { print "theselines"; if ( /$pat[1]/ && /$pat[4]/) { } } } } }
However the matching statements don't seem to want to accept the match for 2matches with the (and) operator. I'd assume they would but I don't know how to say if you match this and this then print this with the proper syntax. I'm lost.

Please Help.
The Brassmon_k

In reply to pat match mult/lines mult/pat by brassmon_k

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.