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

Hi Monks,

I'm getting the following message in webserver's error_log:

Prototype mismatch: sub main::localtime (;$) vs none at /home/httpd/ht +ml/ds/vn.pl line 12
Lines 11 and 12 of my script are:
use Time::localtime; use POSIX qw (locale_h localtime);
I need to use both modules. Is it possible to get rid of this (warning?) message?

--dda

Replies are listed 'Best First'.
Re: Prototype mismatch when using two modules with the same function
by Tomte (Priest) on Jun 21, 2003 at 11:46 UTC

    First guess: use one of the functions with the fully qualified name:

    use Time::localtime; use POSIX qw(locale_h); [...] POSIX::localtime(); localtime() # package Time::localtime
    should work, if I'm not completly mistaken.

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.

      It works. Thanks!

      Most funny thing is that I used POSIX::localtime with the fully qualified name already. So I just removed 'localtime' from 'use POSIX' statement. :)

      --dda

Re: Prototype mismatch when using two modules with the same function
by PodMaster (Abbot) on Jun 21, 2003 at 12:24 UTC
    perldoc Time::localtime
    DESCRIPTION
    This module's default exports override the core localtime() function ...
    
    perldoc POSIX
    localtime
            This is identical to Perl's builtin "localtime()" function for
            converting seconds since the epoch to a date see "localtime" in
            perlfunc.
    
    This is mostly true. The difference is that POSIX::localtime demands you pass it an argument, while CORE::localtime does not (it assumes the value of time):
    C:\>perl -e"die ~~localtime" Sat Jun 21 05:23:53 2003 at -e line 1. C:\>perl -MPOSIX=localtime -e"die ~~localtime" Usage: POSIX::localtime(time) at -e line 1 C:\>

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Prototype mismatch when using two modules with the same function
by atnonis (Monk) on Jun 21, 2003 at 19:57 UTC
    you can also call directly localtime() from each module
    for example POSIX::localtime() and Time::localtime()
    atnonis!