in reply to Re^2: How to creater your own Perl modules/libraries?
in thread How to creater your own Perl modules/libraries?

Hi,

Just want to confirm that the 1; is not necessary?

  • Comment on Re^3: How to creater your own Perl modules/libraries?

Replies are listed 'Best First'.
Re^4: How to creater your own Perl modules/libraries?
by JadeNB (Chaplain) on Nov 23, 2009 at 12:31 UTC

    I probably should have been more careful. It is necessary that your module return something true, and the easiest way to make sure that it does is to put 1; at the end of the source file *. All that I was saying was that what is actually returned may be anything true, including 1, "I'm a true string", or [ qw/references are always true/ ].

    To put it briefly: don't leave off the 1; at the end without a good reason (although the good reason may be “I thought of something funnier”). If you do leave it off, then do a simple test import of your module just to make sure that it can be done.

    * To be precise, this requires that you haven't done something tricky earlier, like returning earlier in the source file.