my $i=0; while <$input>{ if (/^[A-Z]){ $AA[$i][0] = $_; my $j=1; } else{ $AA[$i][$j] = $_; $j++; } $i++; }