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
best of luck#!/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; }
|
|---|