Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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 imbibing at the Monastery: (7)
As of 2014-12-17 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (40 votes), past polls