I can have a constructor like this :
sub create {
my $class = shift;
my $self = {};
return bless $self,$class;
}
and when I create an object, I can write this:
my $object = create Object;
Is this:
my $object = Object::create("Object");
the only equivalent to that constructor call?
No, the equivalent call is
If you use the fully qualified name of the
createfunction without the arrow syntax, you aren’t going through Perl’s OO method dispatch, and therefore any inherited methods will not work.The arrow syntax is preferred over the “indirect”
create Objectsyntax. For the reasons why, see this question.