Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How can I make a string unique (quicker than my approach at least)

by syphilis (Archbishop)
on Apr 02, 2024 at 00:20 UTC ( [id://11158640]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-05-18 04:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found