Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: "Intelligent" array joining

by jeffa (Bishop)
on Feb 05, 2004 at 21:25 UTC ( [id://326892]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @union = sort grep { not $seen{$_}++ } (@union, @array3);
    
  2. or download this
    my @array1 = ([b=>1], [d=>3], [z=>4], [e=>5]);
    my @array2 = ([a=>2], [b=>1], [z=>4]);
    my @array3 = ([d=>3], [e=>5]);
    
  3. or download this
    my %seen;
    my @union = grep { not $seen{$_->[0]}++ } (@array1, @array2);
    ...
    
    use Data::Dumper;
    print Dumper \@union;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-03-19 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found