Why am I getting “called too early to check prototype” warnings in my Perl code?

前端 未结 5 722
你的背包
你的背包 2021-02-07 13:01

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 d

5条回答
  •  花落未央
    2021-02-07 13:45

    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.

提交回复
热议问题