Perl: Left padding an integer using sprintf

Using the function sprintf() of Perl, you can easily left pad any given integer number easily. The sprintf() function is similar to use like other programming languages. I'm giving an example of showing a given integer number with 5 field, where left sides will filled with zeros if any.


my $integer = 10;
$integer = sprintf("%05d", $integer);
print "$integer\n";


Just a simple left padding.

Comments