in reply to
Re^2: trim leading & trailing whitespace
in thread trim leading & trailing whitespace
$_ = " no \n \n \n they \n \n won't \n\n\n";
All blank lines are gone.
I see what you mean now. I thought you were suggesting it would remove the newline characters, not just the blank lines. Your way is more correct.
How about this:
$_ = " yes \n \n \n they \n \n will \n\n\n";
% perl 443391.pl
the lowliest monk
Perhaps replace the \b(.*?) with (\S.*?).
Still, you're not running this with warnings enabled, are you? Both $1 and $2 are optional, so both can be undef, but you use their value regardless. This runs without warnings:
shiny regexes and rules offered by Perl 6
other CPAN module
by looking at it on my monitor
I print it and I read it in spare time
first I convert it into $FORMAT, then I parse it
I hire someone to do it
using my custom module
I write a brand new language to do the task
on the server where I play as human, XML is forbidden
what is XML?
I speak XML natively
I write a new grammar for Perl 6
some other way
Results (368 votes),