Perl

Why a Perl class (or module) should return something at the end of the file? Check the example.

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

If we want to use a Perl module (import a class), this module should end in a value different than 0. This is necessary because if we try to import the class and it has a false value, we will not be able to use it.

package A;

sub new { return bless {}, shift; };
sub printMethod { print "A\n"; };

1;