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... }
In reply to Re^2: How can I make a string unique (quicker than my approach at least)
by Timka
in thread How can I make a string unique (quicker than my approach at least)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |