Logo

Programming-Idioms

History of Idiom 156 > diff from v12 to v13

Edit summary for version 13 by daxim:
New Perl implementation by user [daxim]

Version 12

2019-09-26, 18:07:03

Version 13

2019-09-28, 09:13:10

Idiom #156 Format integer with zero-padding

Assign to string s the value of integer i in 3 decimal digits. Pad with zeros if i < 100. Keep all digits if i1000.

Idiom #156 Format integer with zero-padding

Assign to string s the value of integer i in 3 decimal digits. Pad with zeros if i < 100. Keep all digits if i1000.

Extra Keywords
pad leading fixed width
Extra Keywords
pad leading fixed width
Code
my $s = sprintf '%03d', $i;
Doc URL
http://p3rl.org/sprintf