foreach my $elA (@arA) { map { ($elA eq $_) and push @{$all{$elA}}, "$_ - from Array B" } @arB; map { ($elA eq $_) and push @{$all{$elA}}, "$_ - from Array C" } @arC; }