Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You could read each record into an array, and check it as a unit:

#!/usr/bin/env perl use strict; use warnings; use feature qw(say); use List::Util qw(first); my $rec_no = 0; my @record; my $msisdn; while(<>){ chomp; if(/^<SUBBEGIN/){ @record = ($_); $msisdn = undef; say "Found record: ", ++$rec_no; next; }elsif(/^<SUBEND/){ push @record, $_; check_record(\@record); @record = (); }elsif(/^\s*MSISDN=(\d+);/){ $msisdn = $1; say "Record $rec_no: MSISDN = $msisdn"; }else{ push @record, $_; } } exit 0; sub check_record { my $listref = shift; if( first {/^\s*CF=(CFU-TS10-ACT-(NONE|\d+))/} @{$listref} and first {/^\s*CF=(CFB-TS10-ACT-(NONE|\d+))/} @{$listref} ){ say "this case is found here ....."; } }

It's a bit of a brute-force solution, but it should work.

Sample output:

$ ./t.pl Found record: 1 Record 1: MSISDN = 1234567890 this case is found here ..... Found record: 2 Record 2: MSISDN = 1234567890 this case is found here .....

In reply to Re: Check multiple lines exist in a record by jeffenstein
in thread Check multiple lines exist in a record by gbwien

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found