On 7/14/05, Beast <[EMAIL PROTECTED]> wrote: > > I coudn't find any reference (yet) the meaning of 0; or 1; in the end of > perl program.
In the examples in "perldoc perlmod" you will find 1; # don't forget to return a true value from the file This is needed when you do a 'require' over a Perl module (which is a Perl package in a file). The same applies to 'use' which does a 'require' as its first step. Perl programs or packages within the same file don't need this. Or else a program simple as 'print("Hello, World"); undef" would not work, but it does. As Chris Devers has said it has to do with the return value of the last statement. This is interpreted by 'require' as meaning everything was fine during the initialization of the Perl module. Most of the time, we finish the module just with "1;", but more deeper things could be done. An example is a Perl module attached to a configuration file: it that configuration could not be read, it is better to die than to continue. (This is not the perfect example: something sensible could be done with defaults rather than blowing in user's face). For references, take a look at "perldoc -f require". > It means exit or return value? when I explicitly type "return 0;" it > gives error, You return only from a sub. > but when I give "exit 100;" the value of $$ isn't 100 anyway. 'exit' finishes the program immediately. $? (if in shell) catches the exit code: $ perl -e "exit(100)" $ echo $? 100 Regards, Adriano. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>