for $i (1 .. $ARGV[0]){ open xyz, "< ".$ARGV[$i]; $l=0; while (){ @line = split; @z[$i][$l] = [@line]; $l++; } close xyz; }