What are valid Perl module return values?

后端 未结 6 1314
暗喜
暗喜 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:42

    Anything is a valid return value. If you want the require to succeed, it needs to be a true value. If you don't want the require to succeed (e.g. unsupported platform, missing library), use a false value.

    To see what other people have used as return values, check out Acme::ReturnValue.

    People don't expect to use the return value for anything, so I wouldn't confuse people by trying to do that, no matter how clever it seems at the time. :)

提交回复
热议问题