Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re (tilly) 2: A C-like brain in a Perl-like world

by tilly (Archbishop)
on Sep 27, 2001 at 00:01 UTC ( [id://114927]=note: print w/replies, xml ) Need Help??


in reply to Re: A C-like brain in a Perl-like world
in thread A C-like brain in a Perl-like world

Using keys in this way causes stringification of values. If your arrays have objects or references in them, this will bite. Also note that that 2 for 1 map was slow until Perl 5.6.1. The following is therefore how I do that:
sub unique_merge { my %seen; grep !$seen{$_}++, @_; }
Side benefit? I don't lose the order of the incoming elements. :-) But, as with all hash approaches, my definition of "unique" is "stringifies the same". That is not always the appropriate definition to use.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-25 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found