What does “1;” mean in Perl?

前端 未结 7 776
梦如初夏
梦如初夏 2020-12-24 11:36

I have come across a few Perl modules that for example look similar to the following code:

package MyPackage;

use strict;
use warnings;
use constant PERL510         


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 12:26

    From the documentation for require:

    The file must return true as the last statement to indicate successful execution of any initialization code, so it's customary to end such a file with 1; unless you're sure it'll return true otherwise. But it's better just to put the 1; , in case you add more statements.

提交回复
热议问题