Friday, September 23, 2011

Why do Perl modules end with '1' ?

This line ensures the complier that a module is succesfully loaded (via use or require) or executed and evaluates true. It is a way of making sure that it is parsed all the way to the end of the file. By default, this value is usually 1 though it can be any true value. Therefore it is conventional to end .pm and .pl files with a 1 to provide this value. Moreover, the modules are required to return a value to signal if the require or use directive succeeds or fails. It is a "common fix" to avoid error.

No comments :