in reply to How can I make a string unique (quicker than my approach at least)
use strict; use warnings; use List::Util qw(uniq); while (<DATA>) { my ($id, @names) = split (/\n|\t|-/,$_); print "$id\t",join("-",uniq(@names)),"\n"; #update:parens needed fo +r join args } =Prints ID1 nick-john-helena ID2 george-andreas-lisa-anna-matthew ID3 olivia-niels-peter-lars =cut __DATA__ ID1 nick-john-helena ID2 george-andreas-lisa-anna-matthew-andreas-lisa ID3 olivia-niels-peter-lars-niels-lars-olivia-olivia
|
|---|