|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: why is the '1;' necessary at the end of perl modules
|
On Thu, May 17, 2001 at 04:29:31PM -0400, Kyle R . Burton wrote:
> I just had a co-worker ask me that question. I was able to confirm that
> it was needed and in fact show a few examples of where not having it (or
> returning a false value) at the end of Perl modules caused them to halt
> the execution of programs that 'required' them, but I am still unable to
> find the (any) documentation that states clearly why it's necessary.
>
> Is the reasoning behind this documented in one of the manpages?
>
> Is it just that the true/false-ness of your module affects weather or
> not it can be loaded via use/require? (and if it compiles of course)
It's documented in perlfunc in the section on require. From
"perldoc -f require":
: The file must return true as the last statement to indicate
: successful execution of any initialization code, so it's customary
: to end such a file with "1;" unless you're sure it'll return true
: otherwise. But it's better just to put the "1;", in case you add
: more statements.
I assume it's not also in the perlfunc documentation for "use" because
use is equivalent to
BEGIN { require Module; import Module LIST; }
and so would be subject to the same rules as require.
--
Walter C. Mankowski
Senior Software Engineer Myxa Corporation
phone: (610) 234-2626 fax: (610) 234-2640
email: walt@myxa.com http://www.myxa.com
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|