in reply to how can I group those links together?

Hello plagent,

In the spirit of TMTOWTDI: You can also use one of the Set modules, such as Set::Tiny:

#! perl use strict; use warnings; use Set::Tiny qw( set ); my @groups; push @groups, set(split) while <DATA>; OUTER: while (1) { for my $i (0 .. $#groups - 1) { for my $j ($i + 1 .. $#groups) { unless ($groups[$i]->is_disjoint($groups[$j])) { $groups[$i] = $groups[$i]->union($groups[$j]); splice @groups, $j, 1; next OUTER; } } } last; } print $_->as_string, "\n" for @groups; __DATA__ A C C E D C L G J K O P I M L K

Output:

17:47 >perl 1468_SoPW.pl (A C D E) (G J K L) (O P) (I M) 17:47 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,