I want Package BLOCK syntax return 1.

I want Package BLOCK syntax return 1.

package Point {
  # foo

I want This is interpreted as the following.

  package Point;

  # foo


In current Perl, module need to return 1 at the end of script. But this is a little strange specification. If package BLOCK syntax return 1;, we don't need to write 1; at the end of module.

Is this difficult?


The class doesn't need to return 1, the file/module does. These are separate tasks and though they are commonly seen together are fully unrelated.

You return a true value at the end of the file so the require knows that everything happened. It has nothing to do with being a module or a package. We talk about this in Intermediate Perl.

I guess you assume that every package is going into a separate file, and therefore a module to load. But if you define several packages into the same file unit, you are going to require Perl to conclude each block with useless return statements. While I cannot see a problem with that (from a practical point of view), I don't see a reason for having it too.

Leave a comment

About Yuki Kimoto

user-pic I'm Perl Programmer. I LOVE Perl. I want to contribute Perl community and Perl users.