Help for this page

Select Code to Download


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