http://www.perlmonks.org?node_id=370148


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