Why the 1 at the end of each perl package?

Because Perl modules are required to return a value to signal if the require directive must succeed (true value returned) or fail (false value returned; this can make sense if the module failed to initialize for some reason).

If you don’t return anything, the interpreter cannot know if the require must succeed or fail; at the same time, since it’s easy to forget to put the true value at the end of the package, it suggests the “common fix” for this error: add a true value as a return.

For some other info/folklore about the modules return value have a look at this question.

Leave a Comment