Eshan_k has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I am seeking perl wisdom again. I have a big file with 5000 lines. I want to print lines between three patterns(basically a block of code). I tried making multi-line regex as follows but seems no help. Till now I tried,
my $beg = qr/^\s*APP>\sSTART_PARTU_8X8\n\s*APP>\sPARTITION_SPLIT/; my $end = qr/^\s*APP>\sEND_PARTU_8X8/; if (/$beg/../$end/){ print "$line\n"; }
Input data:
APP> START_PARTU_8X8 APP> PARTITION_NONE START_PARTU_16X16 APP> END_PARTU_8X8 APP> START_PARTU_8X8 APP> PARTITION_SPLIT START_PARTU_4X4 ........ START_PARTU_4X4 ........ START_PARTU_4X4 ........ START_PARTU_4X4 ........ APP> END_PARTU_8X8 PARTU_16X4 16X16 4X16 APP> END_PARTU_8X8
I want to print lines between pattern (these will be two consecutive lines thats why I am trying multi line regex)
APP> START_PARTU_8X8 APP> PARTITION_SPLIT
and 1st occurrence of
APP> END_PARTU_8X8
Output: START_PARTU_4X4 START_PARTU_4X4 START_PARTU_4X4 START_PARTU_4X4
Can anybody please help/suggest something ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Print lines between multi-line regex pattern
by haukex (Archbishop) on Jun 11, 2018 at 09:56 UTC | |
by Eshan_k (Acolyte) on Jun 21, 2018 at 23:59 UTC | |
|
Re: Print lines between multi-line regex pattern
by tybalt89 (Monsignor) on Jun 12, 2018 at 01:58 UTC | |
by Eshan_k (Acolyte) on Jun 22, 2018 at 00:00 UTC |