What are valid Perl module return values?

后端 未结 6 1321
暗喜
暗喜 2020-12-17 14:39

The common practice in Perl is of course to end modules with 1; so that a call to require can then be checked for success. Is there any reason that the return

6条回答
  •  太阳男子
    2020-12-17 14:43

    The purpose is that if your module returns false, the require can fail at that point. Nobody cares about or relies on the value beyond it being true or false.

    You should follow suit. You are making it so that your modules depend on the actual value beyond whether it is true or false. In the example you gave, for instance, if your require happens to return 1, the require will succeed, but your clever constructor will fail.

提交回复
热议问题