Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://723590]
help
Chatterbox?
[Corion]: :-D
[Discipulus]: i was kidding.. and i was kidded:perl -lne " if (length $_ > $l){$l=length $_;$w=$_}}{print qq($w $l\n)" linux.words

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-10-18 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (243 votes). Check out past polls.

    Notices?