foreach ... { $array[$i][$j]= $value; # or push( @{$array[$i]}, $value); $hash{$i}{$j}= $value; }