in reply to Re^2: trim leading & trailing whitespacein 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:
None - I don't code
0 - Ticker-tape is a purer representation of a Turing Machine
1 - A laptop screen or single monitor desktop workstation
1 - And it's cracked. And I like practicing my trade while lying on a bed of nails
2 - The standard dev kit suits me fine
3 - Fewer than three monitors wouldn't present enough insight into what I'm working on
4 - Everyone else has two or three. I'm not like everyone else
5 - This configuration reminds me of the 1987 5-cylinder VW Passat my parents let me drive in high school
6 - I saw such a thing on the Internet, and had to have it
6 - Because I haven't figured out how to add more
7 - I need all the luck I can get, for this code to work
8 - Because my power strip had eight outlets available
9 - A 3x3 array was the the most I could fit into my Faraday shielded SHTF headquarters
More than 9 - Most of them are just displaying graphs / mock code to make the boss think I'm doing something critical
Results (560 votes). Check out past polls.