in reply to Find unique elements in an array
sub unique { my %x; @x{@_} = @_; values %x }
The reason to use values is that I need to get the unique set from an array of objects, not scalars. (This assumes, of course, that every object has a unique stringification. As I don't overload stringification in my objects, this works. If you do overload stringification ... good luck. Seriously.)
And, the reason for not using references is that I use this function as so:
my @final = map { # Something } unique grep { # Something } map { # Something } @start;
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
|
---|