Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: how do i find common elements of X number of arrays whose names i don't know?

by broquaint (Abbot)
on Jun 28, 2004 at 08:52 UTC ( #370148=note: print w/ replies, xml ) Need Help??


in reply to how do i find common elements of X number of arrays whose names i don't know?

If you don't mind some memory hungry list processing code ... Update: urk, misread the op's question, so here's code that actually makes sense

use DDS; # aka Data::Dump::Streamer my %self = {}; $self->{foo} = [ 1, 2, 3 ]; $self->{bar} = [ 4, 5, 3 ]; $self->{nerd} = [ 3, 4, 8 ]; $self->{geek} = 1; $self->{useless} = 1; my @sets = map {{ map{$_=>undef} @$_ }} grep { 'ARRAY' eq ref } values %$self; my @uniq = grep { my $el = $_; @sets == grep { exists $_->{$el} } @sets; } map keys(%$_), @sets; Dump \@uniq;
HTH

_________
broquaint


Comment on Re: how do i find common elements of X number of arrays whose names i don't know?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2015-07-03 17:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (54 votes), past polls