use strict; use warnings; use Data::Dumper; my @numbers = ('1','1','1','2','2','3','3','4','4','5','6'); my @strings = ('hello','you','tree','people','fun', 'sun','grass','love','food','car','rabbit'); my %hash; for (0..$#numbers){ $hash{$numbers[$_]} .= $strings[$_]; } print Dumper(\%hash); __OUTPUT__ $VAR1 = { '6' => 'rabbit', '4' => 'lovefood', '1' => 'helloyoutree', '3' => 'sungrass', '2' => 'peoplefun', '5' => 'car' };