Next Program Repair Shop 55

GetPadString

     122     sub GetPadString {
     123        my $Integer = shift;
     124        if ($Integer < 10) {
     125                return "0000".$Integer;
     126        } elsif (($Integer >= 10) and ($Integer < 100)) {
     127                return "000".$Integer;
     128        } elsif (($Integer >= 100) and ($Integer < 1000)) {
     129                return "00".$Integer;
     130        } elsif (($Integer >= 1000) and ($Integer < 10000)) {
     131                return "0".$Integer;
     132        } elsif ($Integer >= 1000) {
     133                return $Integer;
     134        }
     135     }

Repeated Code is a Mistake



Next Copyright © 2002 M. J. Dominus