Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I was searching for a while but I cant find any answer.
Is there a possible to make the numbers in the format-string changable?
Instead of the 5 I'd like to be able to put a varibale here but this fails allready because the 'i' for integers would be recognized as part of the variable:sprintf "%05i", $myInt;
Is there a solution beside a long switch?$int = 5; sprintf "%0$inti", myInt;
Thanks in advance, Carl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printf & sprintf: variable number formats
by duff (Parson) on Jan 06, 2004 at 16:35 UTC | |
by Anonymous Monk on Jan 06, 2004 at 16:50 UTC | |
|
Re: printf & sprintf: variable number formats
by dragonchild (Archbishop) on Jan 06, 2004 at 16:35 UTC | |
|
Re: printf & sprintf: variable number formats
by flounder99 (Friar) on Jan 06, 2004 at 19:34 UTC | |
by duff (Parson) on Jan 06, 2004 at 19:41 UTC | |
|
Re: printf & sprintf: variable number formats
by Not_a_Number (Prior) on Jan 06, 2004 at 19:01 UTC | |
|
Re: printf & sprintf: variable number formats
by Roger (Parson) on Jan 07, 2004 at 14:48 UTC |