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

How do I get rid of this warning? Example of my code
#!C:/Perl/bin/perl -w use strict; $| = 1; use CGI::Carp "fatalsToBrowser"; use CGI ":all"; ... my $res = $ua->get( $url_home ); ParseHomePage( \$res->{_content} ); sub ParseHomePage { my $p = HTML::TokeParser->new($_[0]); ... }

Replies are listed 'Best First'.
Re: "Called to early to check prototype"
by Aristotle (Chancellor) on Aug 20, 2004 at 20:50 UTC

    Of course, I'm not sure where the problem is, since you're not using a prototype in the code you show. Anyway:

    Probably the best way: by getting rid of the prototype.

    Failing that: predeclare the sub somewhere at the top of the script (that is, anywhere so long as it's above its first use), as in

    sub foo($$);

    Makeshifts last the longest.

      Update: I'm pretty sure the warning is due to the code calling ParseHomePage() before it has been defined so the interpreter can't check the argument list is acceptable.

      If you run "perldoc perlsub" (in your shell) or just go to perlsub you can read how prototypes work.

      I often write scripts like the following but you can put the actual subroutine code at the top before you call it instead of the declaration.
      #!/usr/bin/perl use strict; # subroutines --------------- sub abc($$); # abc() does x,y,z # main() -------------------- ... # subroutines --------------- sub abc($$) { # abc() does x,y,z # inputs: ... # returns: ... # function code here }