gperetti has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that runs on the crontab that also executes several other perl scripts using the do command.

The secondary scripts worked fine before upgrading to 5.10, but now they are not functioning properly. Specifically, the timelocal function does not return values for the variables ($year, $mon, etc.).

Is there something new in 5.10 that is disallowing the use of timelocal or is there a better way to execute them (other than adding them to the cron as well)?

Any help would be appreciated.

Replies are listed 'Best First'.
Re: Perl 5.10 and timelocal
by almut (Canon) on Apr 16, 2009 at 21:40 UTC
    Specifically, the timelocal function does not return values for the variables ($year, $mon, etc.).

    Are you talking about Time::Local's timelocal, or about the localtime builtin?

    Either way, I can't replicate the issue. Both seem to work fine with 5.10 here.

    use Time::Local; my ($sec,$min,$hour,$mday,$mon,$year) = (0,1,2,3,4,105); my $t = timelocal($sec,$min,$hour,$mday,$mon,$year); ($sec,$min,$hour,$mday,$mon,$year) = localtime($t); print "$sec,$min,$hour,$mday,$mon,$year\n"; # 0,1,2,3,4,105
      Again, thanks for the help.

      It was another script running on a do command that was causing the conflict.

      Much appreciated.

Re: Perl 5.10 and timelocal
by ww (Archbishop) on Apr 16, 2009 at 21:20 UTC
    Did you read the 5.10 delta? Cross-check the timelocal source?

    No guarantees that your answer is in either, but worth checking.

      Thanks for the quick response. It looks like the problem is actually a conflict with another script. Thanks for your help.
Re: Perl 5.10 and timelocal
by ig (Vicar) on Apr 16, 2009 at 21:39 UTC

    Time::Local provides timelocal() which takes arguments like year, month, etc. and returns a time value. Are you using timelocal() when you should be using localtime()? Or is there some other timelocal()?

    It might help if you posted a short sample script and relevant input, if any, and output data that demonstrates the problem. Your operating system might also be relevant.