This is correct. When you include something the last line has to return a true value, so people often stick a 1; at the end. Consider it a bit of plumbing that a module or library just has to have.

Dan Muey wrote:

At the end of a lib file ( in the script you have require lib.lib; and lib.lib doesn't have #!/usr/bin/perl because it's a library not a script ) you put a 1; so that the require statement returns true. I believe it's a boolean thing.

So if it does a require and can't do it ( ie gets 0 returned instead of the 1 that we return put at the end with 1; ) then it gives you an error and quits so that the script doesn't do anything stupid since it doesn't have everything it's supposed to have to run.

It's at the end also so that it gets returned only after everything else in the lib works out ok.

I believe it it the same as return 1;

I don't see require used much anymore because most everybody uses modules but you could also use it in routines that are in the same script if you wantsed to do a boolean check on something.

I could be bit off, if I am please let me know.
Thanks

Dan



Greetings!

Dan Muey's stumpy.lib file, quoted below, ends with a statement consisting of a single contstant value: "1;". This is the second time I've seen this today. What is its purpose?

Thanks!

RobR

--- Dan Muey <[EMAIL PROTECTED]> wrote:

sub stumpy_function1 {

use CGI;
blah blah blah
}

sub stumpy_function1 {

use CGI;
blah blah blah
}

1;

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


--
Benjamin J. Siders
Software Engineer



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to