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


in reply to printing 20 characters in a line.

If you don't mind losing $str:

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


GreetZ!,
    ChOas

print "profeth still\n" if /bird|devil/;

Replies are listed 'Best First'.
Re^2: printing 20 characters in a line.
by ig (Vicar) on Nov 14, 2008 at 09:24 UTC

    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";