in reply to Remove whitespace in string and maintain overall length
Use tr to squelch the spaces; and the return value plus a little math to pad to the required length:
$s = 'fred bill john';; $s .= ' 'x ( 37 - length( $s ) + $s =~ tr[ ][]s ); print "'$s'";; 'fred bill john '
|
|---|