in reply to Re: How to end a Perl script
in thread How to end a Perl script

You will also see this one, or any other true value ending packages in the middle of a file if there are several packages in the same one.

You are correct that you will see this, but it's utterly unnecessary. The true value is there to placate "require." It has absolutely nothing to do with "package." Ending every package with "1;" is like buying a ticket on the Cargo Cult Express.

-sam

Replies are listed 'Best First'.
Re: Re: Re: How to end a Perl script
by Dog and Pony (Priest) on May 02, 2002 at 23:15 UTC
    That is true, as I am aware of (see my no-pun remark above). I still put them there, to a) mark the end of a package in an easily readable way (yes, I want that in addition to a new package declaration), and b) so I won't forget it if I decide to move it to a separate file. Cargo Cult or no, I see no error in that practice, at least not for those reasons?

    But it is ok to point that difference out, of course.


    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.
      Cargo Cult practices are very rarely "wrong" in the sense of causing bad results. More often they are, like this one, just plain unnecessary. Instead of a cryptic "1;" you could write "# end of package Foo::Bar." And if you're worried about forgetting the "1;" when you move the package to a new file, well, don't. Perl will be happy to remind you when you try to load the new file!

      -sam

        Sorry to keep this going, but I do not see what the win would be by doing it your way. Maybe it fulfills some way of doing it that some guru has claimed is the best (yes, I remember the debate over Cargo Cult programming). I don't say it is bad doing it your way, I don't see what the big deal is actually.

        Using "1;" is as readable as a comment to me and most others - actually, you could think of it as one if you wish? Or is comments just plain unnecessary too (I mean, perl will run without them)? Sorry about that sarcasm, but it really looks like "Cargo Cult" is used as a buzzword this time (again).

        Again, sorry to keep the discussion alive like this.


        You have moved into a dark place.
        It is pitch black. You are likely to be eaten by a grue.
Re^3: How to end a Perl script
by Anonymous Monk on Oct 15, 2009 at 21:14 UTC
    __END__ Anything past that is treated as a comment.