Process record by record rather than line by line (as suggested by Your Mother) then top-and-tail and use split to break into line items then key/value pairs, populating a HoA structure. Then use grep to see if both items of interest are present. I added a record with one item missing to test.

use strict; use warnings; use 5.022; open my $inFH, q{<}, \ <<__EOD__ or die qq{open: < \ HEREDOC: $!\n}; <SUBBEGIN IMSI=12345678495452; MSISDN=1234567890; DEFCALL=TS11; CURRENTNAM=BOTH; CAT=COMMON; TBS=TS11&TS12&TS21&TS22; VLRLIST=10; SGSNLIST=10; SMDP=MSC; CB=BAOC-ALL-PROV; CB=BOIC-ALL-PROV; CB=BOICEXHC-ALL-PROV; CB=BICROAM-ALL-PROV; CW=CW-ALL-PROV; CF=CFU-ALL-PROV-NONE-YES-NO-NONE-YES-65535-NO-NO-NO-NO-NO-NO-N +O-NO-NO-NO; CF=CFB-ALL-PROV-NONE-YES-YES-NONE-YES-65535-NO-NO-NO-NO-NO-NO- +NO-NO-NO-NO; CF=CFU-TS10-ACT-NONE-YES-NO-NONE-YES-65535-YES-YES-NO-NO-NO-NO +-NO-NO-NO-NO; CF=CFNRY-ALL-PROV-NONE-YES-YES-NONE-YES-65535-NO-NO-NO-NO-NO-N +O-NO-NO-NO-NO; CF=CFNRC-ALL-PROV-NONE-YES-NO-NONE-YES-65535-NO-NO-NO-NO-NO-NO +-NO-NO-NO-NO; CF=CFB-TS10-ACT-NONE-YES-NO-NONE-YES-65535-YES-YES-NO-NO-NO-NO +-NO-NO-NO-NO; CF=CFD-TS10-REG-9144455778-YES-YES-25-YES-65535-YES-YES-NO-NO- +NO-YES-YES-YES-YES-NO; TCSISTATE=YES; OCSISTATE=YES; CONTROL=SUB; WPA=0; GS=HOLD&MPTY&ECT&CLIR&CLIP; CLIRES=TEMPALLOW; CLIPOC=NO; OCSI=10; CFSMS=ACT-10-914366488325207-YES-YES-NO-NO-NO; ARD=PROV; SUBRES=ALLPLMN; IST_ALERT_TIMER=120; IST_ALERT_RESPONSE=2; SUB_AGE=0; MIMSI=240076400029999-ONELIVE-2-2-1-0-0; MIMSI=232191400029999-ONELIVE-1-1-1-0-0; SID=2805158185721065; MCSISTATE=YES; CLRBSG=CLIP-YES-NO-NO-NO-NO; UPLCSLCK=NO; UPLPSLCK=NO; DEFOFAID=10; EPS_PROFILE_ID=1; TGPPAMBRMAXUL=50000000; TGPPAMBRMAXDL=150000000; ARD_EXT=NULL-NULL-NULL-N3GPPNOTALLOWED; FRAUDTPL_ID=10; HLR_INDEX=1; LTEAUTOPROV=NO; PSSER=1-1-10-1-NONE-DYNAMIC-00000000; EPSSER=1-10-10-1-NONE-DYNAMIC-00000000-1; MPS=NO; <SUBEND <SUBBEGIN IMSI=12345678495452; MSISDN=1234567890; DEFCALL=TS11; CURRENTNAM=BOTH; CAT=COMMON; TBS=TS11&TS12&TS21&TS22; VLRLIST=10; SGSNLIST=10; SMDP=MSC; CB=BAOC-ALL-PROV; CB=BOIC-ALL-PROV; CB=BOICEXHC-ALL-PROV; CB=BICROAM-ALL-PROV; CW=CW-ALL-PROV; CF=CFU-ALL-PROV-NONE-YES-NO-NONE-YES-65535-NO-NO-NO-NO-NO-NO-N +O-NO-NO-NO; CF=CFB-ALL-PROV-NONE-YES-YES-NONE-YES-65535-NO-NO-NO-NO-NO-NO- +NO-NO-NO-NO; CF=CFU-TS10-ACT-NONE-YES-NO-NONE-YES-65535-YES-YES-NO-NO-NO-NO +-NO-NO-NO-NO; CF=CFNRY-ALL-PROV-NONE-YES-YES-NONE-YES-65535-NO-NO-NO-NO-NO-N +O-NO-NO-NO-NO; CF=CFNRC-ALL-PROV-NONE-YES-NO-NONE-YES-65535-NO-NO-NO-NO-NO-NO +-NO-NO-NO-NO; CF=CFD-TS10-REG-9144455778-YES-YES-25-YES-65535-YES-YES-NO-NO- +NO-YES-YES-YES-YES-NO; TCSISTATE=YES; OCSISTATE=YES; CONTROL=SUB; WPA=0; GS=HOLD&MPTY&ECT&CLIR&CLIP; CLIRES=TEMPALLOW; CLIPOC=NO; OCSI=10; CFSMS=ACT-10-914366488325207-YES-YES-NO-NO-NO; ARD=PROV; SUBRES=ALLPLMN; IST_ALERT_TIMER=120; IST_ALERT_RESPONSE=2; SUB_AGE=0; MIMSI=240076400029999-ONELIVE-2-2-1-0-0; MIMSI=232191400029999-ONELIVE-1-1-1-0-0; SID=2805158185721065; MCSISTATE=YES; CLRBSG=CLIP-YES-NO-NO-NO-NO; UPLCSLCK=NO; UPLPSLCK=NO; DEFOFAID=10; EPS_PROFILE_ID=1; TGPPAMBRMAXUL=50000000; TGPPAMBRMAXDL=150000000; ARD_EXT=NULL-NULL-NULL-N3GPPNOTALLOWED; FRAUDTPL_ID=10; HLR_INDEX=1; LTEAUTOPROV=NO; PSSER=1-1-10-1-NONE-DYNAMIC-00000000; EPSSER=1-10-10-1-NONE-DYNAMIC-00000000-1; MPS=NO; <SUBEND __EOD__ my @records = do { local $/ = qq{\n<SUBEND \n}; <$inFH>; }; close $inFH or die qq{close: < \ HEREDOC: $!\n}; chomp @records; my $recNo = 0; foreach my $record ( @records ) { $record =~ s{<SUBBEGIN\n\s+}{}; my @itemLines = split m{\n\s+}, $record; my %items; foreach my $itemLine ( @itemLines ) { my( $key, $value ) = split m{=}, $itemLine; push @{ $items{ $key } }, $value; } say q{Record No. }, ++ $recNo, ( 2 == grep m{CF[BU]-TS10-ACT}, @{ $items{ CF } } ) ? q{ - Both present} : q{ - One or both missing}; }

The output.

Record No. 1 - Both present Record No. 2 - One or both missing

I hope this is helpful.

Update: Corrected shonky wording ... and later deleted spurious square bracket.

Cheers,

JohnGG


In reply to Re: Check multiple lines exist in a record by johngg
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":



  • 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.