in reply to Re: How can I make a string unique (quicker than my approach at least)
in thread How can I make a string unique (quicker than my approach at least)
I use that snippet sometimes since some older version of List::Util do not include a uniq function.
The code means:
sub uniq { my %h; # Keep track of things seen. grep { # 4: Return items seen only once. not $h{$_}++ # 2: Item is not (yet) be seen. # 3: ++ would then say item was seen. } @_; # 1: For each input... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How can I make a string unique (quicker than my approach at least)
by Timka (Acolyte) on Apr 03, 2024 at 04:38 UTC |