in reply to How can I make a string unique (quicker than my approach at least)

... and then make this array unique and print the unique elements

For this part of the operation I would think that List::Util::uniqstr() is what you want.
use warnings; use strict; use List::Util qw(uniqstr); my $str = 'olivia-niels-peter-lars-niels-lars-olivia-olivia'; my @s = split /\-/, $str; print "@s\n"; my @s_new = uniqstr(@s); print "@s_new\n"; __END__ Outputs: olivia niels peter lars niels lars olivia olivia olivia niels peter lars
Cheers,
Rob
  • Comment on Re: How can I make a string unique (quicker than my approach at least)
  • Download Code