Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: trivial wrapping

by snafu (Chaplain)
on Nov 18, 2002 at 19:36 UTC ( [id://213860]=note: print w/replies, xml ) Need Help??


in reply to trivial wrapping

How about this?

use strict; my $width = 60; while ( <DATA> ) { chomp; my ($len,$more); my $char; next if ( /^[^\w\d]/ ); $char = substr($_,0,1); if ( ($len = length()) < $width ) { $more = $width - $len; print $_ . $char x $more,"\n"; } else { print "$_\n"; } } ## __DATA__ 111111111111111111111 222222222222222222222 333333333333333333333 111111111111111111111 222222222222222222222 333333333333333333333
output was:
perl monks1.pl 111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333 111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333

_ _ _ _ _ _ _ _ _ _
- Jim
Insert clever comment here...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://213860]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2024-04-16 14:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found