for my $index (0 .. $#other_array) { push @{$lookup{$other_array[$index]}}, $index; } #### for my $item (@first_array) { if($lookup{$item}) { foreach my $where (@{$lookup{$item}}) { # ... } } }