http://qs321.pair.com?node_id=98894


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