Help for this page

Select Code to Download


  1. or download this
    $u = sprintf "%06d", $u;
    
  2. or download this
    $u =~ s/(\d+)/"0"x(6-length($1)).$1/e; if length($u) < 6;
    
  3. or download this
    if($u=~/^\d{4}$/){$u=~s/\d\d\d\d/00$u/;}
    if($u=~/^\d{5}$/){$u=~s/\d\d\d\d\d/0$u/;}
    # but better written as:
    #  $u = "00$u" if $u =~ /^\d{4}$/;
    #  $u = "00$u" if length($u) == 4;  # if you know it's digits