in reply to Strange error in GD::Graph::Map

You're calling a sub before it's defined.

For example, doing::

#!/tools/bin/perl -w greet('world'); sub greet ($) { print "Hello $_[0]!\n"; }
gives:
main::greet() called too early to check prototype at .//cte line 2. Hello world!

Replies are listed 'Best First'.
Re: Re: Strange error in GD::Graph::Map
by liu (Initiate) on May 10, 2004 at 15:57 UTC
    thanks you very much for your reply, for a normal use, ususally the code for subroutine is at the last of script?
      You can put the subroutine definition just about anywhere. But if you're going to declare prototypes, that must happen before your first call to the sub.

      Just don't use prototypes. You really don't need them, really.


      Dave