in reply to Generating standard length strings

As nobody has mentioned it already, there is another way:

sub rpad { pack "A$_[1]", $_[0]};

Replies are listed 'Best First'.
Re^2: Generating standard length strings
by crashtest (Curate) on Apr 14, 2005 at 19:20 UTC
    Note that your sub will cut off the input string if its length is larger than the padding width:
    sub rpad { pack "A$_[1]", $_[0] }; my $string = 'averylongstringthatislongerthan10charsforsure!'; print "]", rpad($string, 10), "[\n"; __END__ ]averylongs[
    I am not sure if that is what the OP intended.