in reply to Re: how to use matching operator on newlines
in thread how to use matching operator on newlines
One option to avoid slurping and would be to set $/ to the double return:
perl -i -pe 'BEGIN{$/="\n\n"} s/\n\n/\n/;' foo.txt
Another option would be to set $/ and $\ (Yay, output format!) and chomp it:
perl -i -pe 'BEGIN{$/="\n\n";$\="\n"} chomp;' foo.txt
-i added back in per kyle's post. Also, ++ to ikegami, too!
--
$you = new YOU;
honk() if $you->love(perl)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: how to use matching operator on newlines
by ikegami (Patriarch) on Jan 03, 2007 at 21:37 UTC | |
Re^3: how to use matching operator on newlines
by kyle (Abbot) on Jan 03, 2007 at 21:44 UTC |
In Section
Seekers of Perl Wisdom