what is purpose of 1; at end of scripts

Discussion in 'Perl Misc' started by Danny, May 1, 2004.

  1. Danny

    Danny Guest

    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
    Danny, May 1, 2004
    #1
    1. Advertising

  2. 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
    Tad McClellan, May 1, 2004
    #2
    1. Advertising

  3. 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
    Gregory Toomey, May 1, 2004
    #3
  4. Danny

    Sam Holden Guest

    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
    Sam Holden, May 1, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    334
  2. Jan Danielsson
    Replies:
    8
    Views:
    610
    Mike Meyer
    Jul 22, 2005
  3. Jp Calderone
    Replies:
    0
    Views:
    443
    Jp Calderone
    Jul 21, 2005
  4. davidj411
    Replies:
    0
    Views:
    481
    davidj411
    Jun 27, 2008
  5. Replies:
    13
    Views:
    514
    Anno Siegel
    Sep 10, 2007
Loading...

Share This Page