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

or, to avoid modifying $str and be rid of trailing spaces

my $tmp = $str; $tmp =~ s/((?:\s*\d+){20})/$1\n/g; print OUT "$tmp\n";

update: get rid of leading spaces

my $tmp = $str; $tmp =~ s/\s*((?:\s*\d+){20})/$1\n/g; print OUT "$tmp\n";