in reply to why do some perl files end with 1;

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.

Replies are listed 'Best First'.
Re^2: why do some perl files end with 1;
by Limbic~Region (Chancellor) on Feb 21, 2008 at 15:14 UTC

      I share my favorite HEREDOC delimiter in the same spirit.

      print <<"AsPhynCteRsAyswHat";

      Another dev did write to ask me once.

Re^2: why do some perl files end with 1;
by Narveson (Chaplain) on Feb 21, 2008 at 15:23 UTC

    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?

      Some good ones.
      • Explicit and correct: from List::Maker
        1; # Magic true value required at end of module
      • Epitaph: at Acme::DonMartin
        'This module is dedicated to Don Martin' ; 1931-2000
      • Identify your package: from nuffin's packages:
        __PACKAGE__;
      • Remarkable quote: at WWW::CPAN
        "I didn't do it! -- Bart Simpson";
      • the end of Sex
      Favorite example:

      return 1; # module loaded successfully