http://qs321.pair.com?node_id=723570


in reply to Re: printing 20 characters in a line.
in thread printing 20 characters in a line.

Either you don't need $cnt, or you don't need to iterate over the indexes.
for (0..$#array){ if ($_ % 20 == 19){ print OUT "$array[$_]\n"; } else{ print OUT "$array[$_] "; } }
for (@array){ if (++$cnt % 20 == 0){ print OUT "$_\n"; } else{ print OUT "$_ "; } }

It's probably worth noting the last line has a trailing space and isn't terminated.