Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Perl

Idiom #215 Pad string on the left

Prepend extra character c at the beginning of string s to make sure its length is at least m.
The length is the number of characters, not the number of bytes.

$s = $c x ($m - length($s)) . $s;
s = s.PadLeft(m, c);

New implementation...