procmail
[Top] [All Lists]

Re: Getting the Time

1995-12-08 11:31:44

sysop(_at_)mhs(_dot_)scbbs(_dot_)com said:
 However, the structure I used from my Perl book doesn't appear to work:
 $currtime = time();  
 $timelist=localtime($currtime);

It won't if you are using perl version 4. This is because localtime returns an 
array which, in your example, you are trying to evaluate in a scalar context - 
$timelist, not an array context - @timelist.
It will work in perl 5.x though.

You can use the following instead:
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
                                                     localtime($currtime);
They will all be numbers, so you have to convert from then to names, but that
is fairly trivial.

Or 
@timelist=localtime($currtime);

to assign to an array

If you have the Camel book (thats Programming Perl by Larry Wall & Randal L. 
Schwartz) it should all be covered in there, pages 262, 320, 159.


cheers,
        dave

-- 
         Dave Smith           |
     drs(_at_)aeolians(_dot_)bt(_dot_)co(_dot_)uk    | In the midst of heat 
there is coolness...
smith_d_r_dave(_at_)bt-web(_dot_)bt(_dot_)co(_dot_)uk| In the midst of hate 
there is love
     tel: +44 1473 647694     | - Phra Agan Yantra


<Prev in Thread] Current Thread [Next in Thread>