... if(exists($final->{$x[$i]})){ print "second\n"; $final->{$x[$i]} = ($final->{$x[$i]}, $f); #### i need to push the $f into $final. } ...