A combination of the already recommended flip-flop inside a grep along with a join and a split breaks the file into records nicely.
knoppix@Microknoppix:~$ perl -E ' > open my $fh, q{<}, \ <<EOD or die $!; > dsfiu > =begin > line1 > line2 > =end > wwefgwf > werfwef > =begin > line3 > line4 > line5 > =end > sadfwfe > dfbsdfbsfd > EOD > > @recs = > split m{(?<==end\n)(?==begin)}, > join q{}, > grep { m{=begin} .. m{=end} } > <$fh>; > > print do { local $" = qq{**********\n}; qq{@recs} };' =begin line1 line2 =end ********** =begin line3 line4 line5 =end knoppix@Microknoppix:~$
I hope this is helpful.
Cheers,
JohnGG
In reply to Re: Regular expression...
by johngg
in thread Regular expression...
by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |