in reply to Generating standard length strings

And just for variety (TIMTOWTDI, after all), I first thought of using pack:
sub pad{ my ($string, $length) = @_; return (length($string) < $length ? pack("A$length", $string) : $st +ring); }
... although after reading all the responses, I agree that sprintf is the best way to go.