#!/usr/bin/perl # https://perlmonks.org/?node_id=1222680 use strict; use warnings; while( <DATA> ) { my ($cluster, $member) = split; print $cluster eq $member ? "\n" x ($. > 1) : ', ', $member; } print "\n"; __DATA__ Osat_a Osat_a # just one cluster member Atha_b Atha_b # >1 cluster member, this & next line = 2 members Atha_b Mtru_c Fves_d Fves_d # this & next 2 lines = 3 cluster members Fves_d Osat_e Fves_d Atha_f Atha_g Atha_g # just 1 cluster member Osat_h Osat_h Osat_h Atha_i Mtru_j Mtru_j # just 1 cluster member
In reply to Re: Processing while reading in input
by tybalt89
in thread Processing while reading in input
by onlyIDleft
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |