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

前端 未结 5 716
你的背包
你的背包 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:42

    Simply remove the () from your subroutine definitions. When you define with (), Perl thinks these are prototypes and you have to define your prototype before you use it.

    Try this......

    use strict;
    f1();
    
    sub f3
    { f2(); }
    
    sub f1
    {}
    sub f2
    {}
    

提交回复
热议问题