in reply to Remove whitespace in string and maintain overall length

sprintf can append space to the end of a string:
use warnings; use strict; my $len = 30; my $address = '123 Main St NE'; $address =~ s/ +/ /g; $address = sprintf "%-${len}s", $address; print ">>>$address<<<\n"; __END__ >>>123 Main St NE <<<

Replies are listed 'Best First'.
Re^2: Remove whitespace in string and maintain overall length
by silentbob343 (Initiate) on Nov 19, 2015 at 19:16 UTC
    Wow. That worked the treat, thanks!

    I am no programmer, but rather pull bits and pieces from the code we have floating around. I've see sprintf, but never knew what it was. Looks like I have another Perl toy to play with.

    Thanks again.