Next | Program Repair Shop | 55 |
I left this one until last because it's so much fun
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 }
This is a perfect example of the world's largest Red Flag:
Repeated Code is a Mistake
Next | Copyright © 2002 M. J. Dominus |