When a module is loaded (via use) the compiler will complain unless the last statement executed when it is loaded is true.
For that reason, Perl modules end with 1;
| [reply] [d/l] |
| [reply] [d/l] |
If you don't like 1, (after reading other replies) you can have any other true value, say 42, the strings 'undef' or 'zero', etc. I wonder what 0E0 would give ... nope, that doesn't work. | [reply] |
parv,
I am rather partial to:
'This statement is false.';
| [reply] [d/l] |
| [reply] [d/l] |
Module authors have the opportunity to use a string in this position. They could say
- 'Hello, world!';
- 'Have a nice day!';
- 'Thank you for using Acme::Foo!';
It's like a comment, except if the user deletes it, their program breaks.
Some CPAN authors do use this opportunity to have a last word. Does anybody have a favorite example?
| [reply] [d/l] [select] |
| [reply] [d/l] [select] |
return 1; # module loaded successfully
| [reply] [d/l] |