#!/usr/bin/perl -w use strict; my @chicago{ qw(tiger bob munch toy) } = (); my @wisconsin{ qw( tiger sara munch toy ) } = (); my @rockford{ qw( tiger sara love toy ) } = (); 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; } my $newIntersection = &intersection( \%chicago, \%wisconsin, \%rockford ); print join(" ", keys %{ $newIntersection }), "\n";