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

I got the following error message when run a Perl script.

Prototype mismatch: sub main::INFINITE: none vs () at C:........../lib/Exporter.pm line 66.

at C:........app.pl line 40.

.

The lines near line 66 of Exporter.pm are (line is at the beginning of each line)

64 sub {require Carp; &Carp::carp} if not $SIG{__WARN__};

65 # shortcut for the common case of no type character

66 *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;.

67}.

.

The lines near line 40 of the app are.

38 use File::Basename;

39

40 use Win32::ChangeNotify;

I use the change notify function with the follwoing

$notify = Win32::ChangeNotify->new($watched_dir, 0, FILE_NOTIFY_CHANGE +_SIZE);
Can someone kindly let me know how to remove the error?

This error seems to be ingored and Perl continues without any problems but I would rather not have it appear.

Replies are listed 'Best First'.
Re: Puzzling Prototype Mismatch Error
by Corion (Patriarch) on Sep 08, 2014 at 15:55 UTC

    It seems that Win32::ChangeNotify exports a subroutine named INFINITE. You (or something else) seems to be overwriting that with something else.

    Search your source code for other mentions of INFINITE or subroutine exports to main:: .

      This is (just one reason) why you should use explicit imports from modules. Don't import INFINITE from Win32::ChangeNotify unless you actually use that. My guess if you've got another module that is importing INFINITE before you implicitly asked Win32::ChangeNotify to import it. But it may not be easy to find what that other module is if you used implicit imports.

      Though, exports -- which module exports are used? can likely help, here. It can also help you change your implicit imports to explicit imports so you actually know and document what is being imported from where when you look at a particular file of Perl code.

      - tye        

Re: Puzzling Prototype Mismatch Error
by Anonymous Monk on Sep 08, 2014 at 15:55 UTC

    It looks like Win32::IPC contains some special treatment of the INFINITE constant, which is conflicting with what Exporter is doing. Since I can't test it here this is a guess: If you're not using the INFINITE constant in your code, you could try use Win32::ChangeNotify '!INFINITE';

    (Please use <code> tags for formatting your code.)

      No, there’s no inherent conflict between Win32::ChangeNotify (or Win32::IPC) and Exporter:

      2:06 >p5u v Win32::ChangeNotify Win32::ChangeNotify C:\Perl\Strawberry\strawberry-perl-5.20.0.1-64bit-PDL\perl\sit +e\lib\Win32\ChangeNotify.pm: 1.09 2:07 >perl -MWin32::ChangeNotify -wE "say INFINITE;" 4294967295 2:07 >perl -MWin32::IPC -wE "say INFINITE;" 4294967295 2:08 >

      Looks like the conflict derives from another sub INFINITE somewhere in the OP’s code, as Corion suggests.

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,