I have a Perl file like this:
use strict;
f1();
sub f3()
{ f2(); }
sub f1()
{}
sub f2()
{}
In short, f1
is called before it is defined. So, Perl throws a warning: "f1 called too early to check prototype". But same is the case with f2
, the only diff being that it is called from inside another subroutine. It doesn't throw a warning for f2
. Why?
What is the best way to resolve this issue?
&f1();
You can completely avoid this issue by not using prototypes in the first place:
use strict;
f1();
sub f3 { f2() }
sub f1 {}
sub f2 {}
Don't use prototypes unless you know why you are using them:
This is all very powerful, of course, and should be used only in moderation to make the world a better place.