Manawydan has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I want to create a random figure between 1 and 9999, but if it's under 4 chars long, I want it to add preceeding zeros (e.g. 0039).
I tried :
$conduit_random = ("%04d",int(rand(9999)));and although it doesn't give an error it doesn't work either! :(
Is it possible to do it this way or have I got the wrong end of the stick?
Cheers!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Formatting randomised data
by davidrw (Prior) on Jun 19, 2005 at 19:39 UTC | |
|
Re: Formatting randomised data
by thundergnat (Deacon) on Jun 19, 2005 at 19:40 UTC | |
by merlyn (Sage) on Jun 19, 2005 at 20:14 UTC | |
by tlm (Prior) on Jun 19, 2005 at 20:38 UTC | |
| |
|
Re: Formatting randomised data
by Manawydan (Initiate) on Jun 19, 2005 at 20:59 UTC | |
by bart (Canon) on Jun 19, 2005 at 22:16 UTC | |
|
Re: Formatting randomised data
by ambrus (Abbot) on Jun 20, 2005 at 09:18 UTC |