~~David~~ has asked for the wisdom of the Perl Monks concerning the following question:
Is there anything shorter or nicer than this?my $longdefectid; if ($defectid < 10){$longdefectid = "00000"."$defectid"} elsif($defectid >= 10 && $defectid < 100){$longdefectid = "0000"." +$defectid"} elsif($defectid >= 100 && $defectid < 1000){$longdefectid = "000". +"$defectid"} elsif($defectid >= 1000 && $defectid < 10000){$longdefectid = "00" +."$defectid"} elsif($defectid >= 10000 && $defectid < 100000){$longdefectid = "0 +"."$defectid"} elsif($defectid >= 100000 && $defectid < 1000000){$longdefectid = +"$defectid"};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Formating Numbers Preceding 0's
by Somni (Friar) on Nov 27, 2007 at 23:52 UTC | |
|
Re: Formating Numbers Preceding 0's
by chrism01 (Friar) on Nov 28, 2007 at 00:34 UTC | |
|
Re: Formating Numbers Preceding 0's
by dwm042 (Priest) on Nov 28, 2007 at 01:40 UTC |