Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: printing 20 characters in a line.

by ChOas (Curate)
on Nov 14, 2008 at 08:48 UTC ( #723590=note: print w/replies, xml ) Need Help??

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


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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://723590]
[Corion]: I hope you had a good weekend!
[marto]: jetlag has really done a number on the kids, it's been a tough week
choroba played with the band on Saturday, so Sunday was very sleepy
[choroba]: managed to release Syntax::Construct with 5.28 support in the night, though
[Corion]: choroba: Whee ;)
[Corion]: marto: Ouch - I would've thought that kids adapt much better, but that's obviously not the case...
[marto]: well, their mother let them sleep till 15:00 & 12:00 last week, which didn't help them adjust :P
[Corion]: I was "productive" over the weekend in the sense that I revived my old "Perlmonks on SQLite" code, which likely means I can get a test instance back up running on my webhost. Small steps :)
[Corion]: marto: Ow, no, that doesn't help at all :)

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2018-06-25 08:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.