Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: •Re: Forcing a string with no spaces to wrap to fit on the screen

by andyf (Pilgrim)
on Jun 09, 2004 at 21:26 UTC ( [id://362901]=note: print w/replies, xml ) Need Help??


in reply to Re: •Re: Forcing a string with no spaces to wrap to fit on the screen
in thread Forcing a string with no spaces to wrap to fit on the screen

Tom, maybe I'm missing something important, but HTML table cells will wrap automatically. Setting width=50% for a cell should force wrapping to a maximum of half the current total column span.

I just tried it and I see the problem about spaces. Hmm. Afaik, somehow spaces are gonna have to go in there somehow. ..
#!/usr/bin/perl my $bigstring = 'qawsedrftgyhujikolplokijuhygtfrdeswaqawsedrftgyhujiko +lp'; my $width = 10; print padit($bigstring,$width,"\n"); sub padit { my $padme = shift; my $width = shift; my $separator = shift; my $position = 0; my $padded; while ($position < length $padme) { $padded .= substr $padme, $position, 1; $position++; if ($position % $width == 0) { $padded .= $separator; } } return $padded; }
best of luck
Andy
  • Comment on Re^2: •Re: Forcing a string with no spaces to wrap to fit on the screen
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-25 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found