for (my $f = 0; $f < @fileNames; $f++) { ...... my $cntRef = $anderesHash{$fileNames[$f]}; my @cntMsgArray = @$cntMsgRef; ...... }