in reply to Check multiple lines exist in a record
#!/usr/bin/perl use strict; use warnings; use feature 'say'; my $HSSIN = shift or die "usage: $0 <inputfile"; open my $infile, $HSSIN or die "Can't open input file"; my ($MSISDN, $cfu_found, $cfb_found); while (<$infile>) { # this is true for all lines between these two markers if (/^\s*<SUBBEGIN/.. /^<SUBEND/) { if (/MSISDN=(.+)/){ $MSISDN = $1; } if (/^\s*CF=CFU-TS10-ACT/){ $cfu_found = 1; } if (/^\s*CF=CFB-TS10-ACT/){ $cfb_found = 1; } } } if ($cfu_found and $cfb_found){ say "cfu and cfb both found and MSISDN is $MSISDN"; }
|
|---|