my @d; $#d = 1_000_000; # presize the array! my $i = 0; while (<>) { chomp; $d[$i++] = [ split ]; }