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