Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > what is purpose of 1; at end of scripts

Reply
Thread Tools

what is purpose of 1; at end of scripts

 
 
Danny
Guest
Posts: n/a
 
      05-01-2004
I notice a lot of scripts that have a 1; at the bottom.
I am new to perl and trying to understand.

Usually at bottom of scripts that do something but do not print to a web
page or print this 1;

Thanks in advance


 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      05-01-2004
Danny <> wrote:

> I notice a lot of scripts that have a 1; at the bottom.



It is not needed in programs, it is needed in libraries.

Is that where you saw them?


> I am new to perl and trying to understand.



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.


> Usually at bottom of scripts that do something but do not print to a web
> page or print this 1;

^^^^^^^^^^^^

Oh. You must be talking about something else then...

.... can't tell what else unless you show us the code you are asking about.


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
Gregory Toomey
Guest
Posts: n/a
 
      05-01-2004
Danny wrote:

> I notice a lot of scripts that have a 1; at the bottom.
> I am new to perl and trying to understand.
>
> Usually at bottom of scripts that do something but do not print to a web
> page or print this 1;
>
> Thanks in advance


Basicly, the last "executed statement" of a script should evaluate to true,
ie 1.

gtoomey
 
Reply With Quote
 
Sam Holden
Guest
Posts: n/a
 
      05-01-2004
On Sat, 01 May 2004 15:19:16 +1000, Gregory Toomey <> wrote:
> Danny wrote:
>
>> I notice a lot of scripts that have a 1; at the bottom.
>> I am new to perl and trying to understand.
>>
>> Usually at bottom of scripts that do something but do not print to a web
>> page or print this 1;
>>
>> Thanks in advance

>
> Basicly, the last "executed statement" of a script should evaluate to true,
> ie 1.


Why?

That is the case for a module or a library, since otherwise it won't work,
but for a script it makes no difference at all what the result of the last
executed statement was.

--
Sam Holden
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Python Scripts with IIS - ASP or Python-based CGI scripts withIIS - which makes more sense? davidj411 Python 0 06-27-2008 04:38 PM
What is required for perl scripts to run correct when launched from rc scripts on HPUX 11? deanjones7@gmail.com Perl Misc 13 09-10-2007 11:58 AM
Stupid question: Making scripts python-scripts Jan Danielsson Python 8 07-22-2005 12:20 AM
Re: Stupid question: Making scripts python-scripts Jp Calderone Python 0 07-21-2005 02:38 PM
Web front-end for python scripts secun@yahoo.com Python 0 01-26-2005 07:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57