$padded = "0" x 10; substr($padded, 0, length $string) = $string;