in reply to Re^6: Shorten a list...
in thread Shorten a list...
A possible solution is close to my first answer.
The statement local ($/, $\) = ('', "\n\n");, sets the INPUT_RECORD_SEPARATOR, $/, to read in paragraphs. A paragraph is lines of text followed by 1 or more blank lines, (2 or more newlines). The OUTPUT_RECORD_SEPARATOR, $\, is set to "\n\n". $\ is printed at the end of every print statement.#!/usr/bin/perl use strict; use warnings; { local ($/, $\) = ('', "\n\n"); while (<DATA>) { chomp; print if tr/\n// > 1; } } __DATA__ >Group 42 0 25ap, >name_06-T_1_0... at 92.00% 1 28ap, >name_06-T_1_0... * >Group 43 0 28ap, >name_07-N_1_0... * >Group 44 0 29ap, >name_07-N_1_0... * >Group 45 0 25ap, >name_03-T_1_0... * 1 25ap, >name_06-T_1_0... at 100.00% 2 25ap, >name_07-N_1_0... at 100.00% 3 25ap, >name_11-N_1_0... at 100.00% 4 25ap, >name_14-T_1_0... at 100.00%
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Shorten a list...
by la (Novice) on Oct 18, 2011 at 17:12 UTC | |
by la (Novice) on Oct 18, 2011 at 18:11 UTC | |
by Cristoforo (Curate) on Oct 18, 2011 at 20:23 UTC |