Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^10: Shorten a list...

by Cristoforo (Deacon)
on Oct 18, 2011 at 20:23 UTC ( #932239=note: print w/replies, xml ) Need Help??


in reply to Re^9: Shorten a list...
in thread Shorten a list...

#!/usr/bin/perl use strict; use warnings; { local $/ = '>Group'; while (<DATA>) { chomp; print ">Group$_" if tr/\n// > 2; } } __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%
prints
>Group 42 0 25ap, >name_06-T_1_0... at 92.00% 1 28ap, >name_06-T_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%
If you want to separate the records with a newline in the output, add a newline in the print. print ">Group$_\n" if tr/\n// > 2;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932239]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2016-09-29 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (545 votes). Check out past polls.