[thelist] Perl-limiting size of returned number?

dwayne dwayne at iconys.com
Sun Jun 17 10:36:21 CDT 2001


hi, adrian,

try:
$file_no = sprintf "%.5s", time(); 

putting a ".number" between the % and the conversion letter will limit 
precision for floating point numbers, give the minimum length for an integer, 
and the maximum length for a string. so you want to treat the number returned 
by time() as a string.

hth

- dwayne

On Sunday 17 June 2001 11:58, Adrian Fischer wrote:
> This is the problem...Im using perl's time as a file number but I only want
> to use the first 5 numbers of the number returned.  I think I can do it
> with sprintf() or printf() but am not sure of the syntax.  Again  think it
> would look something like this:
> <snip>
> $new_file=time;
> $file_no= (sprintf("%0d",$new_file));
> </snip>
> this aint right because this will trim decimals or something.  I want only
> return the first 5 or so places.




More information about the thelist mailing list