$
$ cat f5
some code here
and some more code here
=comment
blabla
blah blah blah
more blah blah
=cut
some code here
some more code here
=comment
blah more blah
=cut
and more code...
$
$ perl -lne 'BEGIN{undef $/} s/^=.*?=cut//msg; print' f5
some code here
and some more code here
some code here
some more code here
and more code...
$
$
tyler_durden
==
Note that there's a blank line in the output for every comment block. If you don't want those either, then -
$
$
$ perl -ne 'BEGIN{undef $/} s/^=.*?=cut\n//msg; print' f5
some code here
and some more code here
some code here
some more code here
and more code...
$
$
$
yes! that works. thank you
but i would like to know HOW it works
why are you use /sm ? is it not 2 different options?? for multi-line and single line?
why need undef$/ if you have /sm ?
how to make the same work in a script inside?
It sets record separator to undef, so whole file will be loaded into $_ variable.
/s effect is that "." matches any character in string, including newline.
/m causes ^ and $ to match not only begin and end of the whole string, but also newline characters inside of it.