[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Time question



At 10:47 am -0500 28/12/99, Ronald J Kimball wrote:
>On Tue, Dec 28, 1999 at 03:02:11PM +0000, John Delacour wrote:
>>  Now I'm a little confused with time.  In MacPerl this does not seem to
>>  return an associative array as I understand from my little O'Reilly crib
>>  it ought to , so that I can't get $time[$year] but have to get $time[5]
>>  as in the script below -- or am I reading too much into the crib?
>
>I'm not sure what you mean by "O'Reilly crib", but localtime() and gmtime()
>have always returned lists of values, as clearly documented in perlfunc.
>
>Also, the syntax for a hash lookup would be $time{year}, not $time[$year].

Further reading in perlfaq5.pod proposes two methods using 
Time:localtime or not using it.  The difference in speed is marked 
owing to the time needed to load the lib, so I shall be sticking to 
the time list.  If the __END_ is uncommented in the script below, it 
will take appreciably longer.


        #!perl -w
        @quicktime = localtime time;
        $qd = $quicktime[3];
        if (length $qd < 2) {$qd = "0$qd"};
        $qm = 1 + $quicktime[4];
        if (length $qm < 2) {$qm = "0$qm"};
        $qy = 1900 + $quicktime[5];
        $qy = substr $qy, 2;
        print "\n$qd\/$qm\/$qy";
        #__END__
        use Time::localtime;
        $d = localtime(time())->mday;
        if (length $d < 2) {$d = "0$d"};
        $m	= 1 + localtime(time())->mon;
        if (length $m < 2) {$m = "0$m"};
        $y =1900 + localtime(time())->year;
        $y = substr $y, 2;
        print "\n$d\/$m\/$y";


This question of the time taken to load libraries (which I've 
discussed briefly with Chris off-list in relation to AE) is bugging 
me.  My machine is not all that slow (180 MHz Motorola) and yet 
scripts that require imported functions are slowed down dramatically.

Perhaps I'm missing something, but surely not everyone is running a 
G3 and this delay must be noticeable to others.  Is there any way of 
avoiding it?  I've tried putting Time in a new folder and putting 
this folder first in the Preferences list, but it makes no difference

JD





# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org