#!/usr/bin/perl -w use strict; my @array1 = qw{ bob larry melon fruit}; my @array2 = qw{ bob larry melon apple}; my array3 = qw{ bob larry fruit apple}; my @comp; push @comp, [@array1]; push @comp, [@array2]; push @comp, [@array3]; ############# # # I'm not sure what to do here to make the @comp AoA compatable with the &intersection subroutine # ############ my $newIntersection = &intersection( \%array1, \%wisconsin, \%rockford ); print join(" ", keys %{ $newIntersection }), "\n"; sub intersection { my ( $i, $sizei ) = ( 0, scalar keys %{ $_[0] }); my ( $j, $sizej ); for ( $j = 1; $j < @_; $j++ ) { $sizej = keys %{ $_[ $j ] }; ( $i, $sizei ) = ( $j, $sizej ) if $sizej < $sizei; } my @intersection = keys %{ splice @_, $i, 1 }; my $set; while ( $set = shift ) { @intersection = grep { exists $set->{ $_ } } @intersection; } my %intersection; @intersection{ @intersection } = (); return \%intersection; }