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

Which warning category is "func() called too early to check prototype at ..."?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re: Which warning category?
by johngg (Canon) on Nov 27, 2013 at 17:54 UTC

    IIRC, doing use diagnostics; increases the verbosity of the warning to the extent that it mentions the category.

    Update: Yes, that seems to be the case.

    $ perl -Mstrict -Mwarnings -E ' > my @arr = qw{ abc #def ghi };' Possible attempt to put comments in qw() list at -e line 2. $ perl -Mstrict -Mwarnings -Mdiagnostics -E ' my @arr = qw{ abc #def ghi };' Possible attempt to put comments in qw() list at -e line 2 (#1) (W qw) qw() lists contain items separated by whitespace; as with l +iteral strings, comment characters are not ignored, but are instead treat +ed as literal data. (You may have used different delimiters than the parentheses shown here; braces are also frequently used.) You probably wrote something like this: @list = qw( a # a comment b # another comment ); when you should have written this: @list = qw( a b ); If you really want comments, build your list the old-fashioned way, with quotes and commas: @list = ( 'a', # a comment 'b', # another comment ); $

    Cheers,

    JohnGG

      use diagnostics;

      Finally, a use for that module :) Many thanks.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        You could still do without, since it just gives you the description available in perldiag :)

Re: Which warning category? (splain)
by Anonymous Monk on Nov 27, 2013 at 23:06 UTC

    If you don't want to run the program again with diagnostics turned on, you can give splain the error message

    $ perl -we" f(3); sub f($){die} " main::f() called too early to check prototype at -e line 1. Died at -e line 1. $ echo main::f() called too early to check prototype at -e line 1. |sp +lain main::f() called too early to check prototype at -e line 1. (#1) (W prototype) You've called a function that has a prototype before + the parser saw a definition or declaration for it, and Perl could not +check that the call conforms to the prototype. You need to either add a +n early prototype declaration for the subroutine in question, or mov +e the subroutine definition ahead of the call to get proper prototype checking. Alternatively, if you are certain that you're calling t +he function correctly, you may put an ampersand before the name to av +oid the warning. See perlsub.