http://www.perlmonks.org?node_id=931720


in reply to Shorten a list...

My program starts by reading in paragraph mode, then chomping. Only groups with more than 1 line can have 1 or more newlines.
#!/usr/bin/perl use strict; use warnings; use 5.014; { local $/ = ""; while (<DATA>) { chomp; print "$_\n" if tr/\n//; # if 1 or more newlines } } __DATA__ Group 1 Group 2 Group 3 Group 3 Group 4 Group 5 Group 5 Group 5
prints:
Group 3 Group 3 Group 5 Group 5 Group 5