On Thu, 14 Jul 2005, Beast wrote:

> I coudn't find any reference (yet) the meaning of 0; or 1; in the end 
> of perl program.

In the absense of an explicit return statement, a block of Perl code 
will return the value of the last statement to any calling code.

For an ordinary script, this doesn't really matter -- it will return 
what it will return. For code that you expect to be called though, like 
a package or module, you have to keep the return value -- and more to 
the point, the truth of the return value -- in mind.

The simplest way to do this is the "1;" end-of-module idiom. I've also 
seen people use random strings like "'true';" or "'pony pony pony';" -- 
but either way has the same result: as long as the truth status of the 
final statement is guaranteed to unconditionally be "true", then the 
module can be used without throwing any errors (or at least, not errors 
because of the return status). 
 
The important bit to keep in mind is the truth value of the last line. 
Using '1;' is a short, simple, guaranteed way to get this truth value.


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to