my @array=split(/ /,$str); my $cnt = 0; map {print "$_ ";($cnt % 20 == 19)? eval{++$cnt;print "\n";}:++$cnt;}@array;