- or download this
sub add_zero { $x = shift; return $x if ( $x > 9 ); return ( '0' . $x
+) if ( $x < 10 ); }
- or download this
sub pad
{
...
return $n if $n =~ /\D/;
return $n > 9 ? $n : "0$n";
}
- or download this
$n = $n =~ /^\d/ ? sprintf('%02d', $n) : $n;