On Jan 23, 2008 6:18 AM, lerameur <[EMAIL PROTECTED]> wrote:

> here is my program:

Have you profiled it, to find out where it's taking time?

> my $time_second1=substr($date1,-4,2);
> my $time_minute1=substr($date1,-6,2);
> my $time_hour1=substr($date1,-8,2);
> my $time_day1=substr($date1,-10,2);
> my $time_month1=substr($date1,-12,2);
> my $time_year1=substr($date1,-14,2);

A series of non-overlapping substr()s on the same string would seem to
be a candidate for a pattern match.

> my $total_seconds1=$time_second1+($time_minute1*60)+
> ($time_hour1*60*60)+($time_day1*24*60*60);
> my $total_seconds2=$time_second2+($time_minute2*60)+
> ($time_hour2*60*60)+($time_day2*24*60*60);
> my $time_difference= $total_seconds1-$total_seconds2;

Isn't there a time-handling module that can do this for you?

>         my  $file_to_print = ( `ls -1c /home/etc/*log | tail -1 `);
> #determine the latest and last document

That shell command could be more efficiently done within perl with
readdir and friends.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to