control153 has asked for the wisdom of the Perl Monks concerning the following question:
i am trying to grab the text (running through various lines) within "AAAAAA" and "BBBBBB" i am using the following code:hello world0 hello world1 hello world2 AAAAAA this is a test of the emergency broadcast system BBBBBB hello world0 hello world1 hello world2 AAAAAA if this had been a real emergency more instructions would have followed BBBBBB hello world0 hello world1 hello world2
this will only print the first "this is a test of the emergency broadcast system" and not the second one ... there will be several chunks and i would like to print them all out (or save them in an array i can manipulate later) ... how do i do this ???undef $/;# read in whole file, not just one line or paragraph while ( <> ) { while ( /AAAAAA(.*?)BBBBBB/sgm ) { print "$1\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: matching several lines
by ikegami (Patriarch) on Feb 05, 2008 at 20:11 UTC | |
|
Re: matching several lines
by Narveson (Chaplain) on Feb 05, 2008 at 18:58 UTC | |
|
Re: matching several lines
by apl (Monsignor) on Feb 05, 2008 at 18:46 UTC | |
|
Re: matching several lines
by kyle (Abbot) on Feb 05, 2008 at 19:59 UTC | |
|
Re: matching several lines
by Narveson (Chaplain) on Feb 05, 2008 at 18:49 UTC | |
|
Re: matching several lines
by Erez (Priest) on Feb 06, 2008 at 14:46 UTC |