Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: is 1; at the end of a PM still necessary in 5.6.1 ?

by Anonymous Monk
on Jul 23, 2001 at 05:58 UTC ( #98894=note: print w/replies, xml ) Need Help??


in reply to is 1; at the end of a PM still necessary in 5.6.1 ?

I find that 1; at the end of a file tends to be hard to see and sometimes gets removed accidently. Is there any reason I can't use return(1); at the end, is there any differences or problems to worry about in doing this?

Replies are listed 'Best First'.
Re: Re: is 1; at the end of a PM still necessary in 5.6.1 ?
by Cirollo (Friar) on Jul 23, 2001 at 17:22 UTC
    It won't be hard to see and probably won't get deleted if you use it the way perlmod does: (thanks crazyinsomniac)

    1; # don't forget to return a true value from the file

    The comment makes things a lot clearer, and should make someone think twice before deleting it.

Re: Re: is 1; at the end of a PM still necessary in 5.6.1 ?
by John M. Dlugosz (Monsignor) on Jul 23, 2001 at 06:17 UTC
    I really don't know what return from the main top-level code of a module does.

    I tried changing the 1 to

    return 1; # script loaded OK.
    on the PM I'm working on, and nothing changed. So I suppose it's just fine. I'd do without the extra parens, though: return is not a function, and I'm not expecting it to be "called" in list context.

    —John

Re: Re: is 1; at the end of a PM still necessary in 5.6.1 ?
by petral (Curate) on Jul 23, 2001 at 16:59 UTC
    The other way to go is just:
    1
    then if you put anything after it you get an error.
    But I've said this before and I'm sure everyone else considers it bad practice and I suppose their right. It just always seems counterproductive to me to add the ';' when that only serves to hide it.

      p

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://98894]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2023-02-04 08:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?