From perldoc perlobj (quoted in this excellent answer):
my $fred = Critter->find("Fred"); $fred->display("Height", "Weight");… the above code is mostly equivalent to:
my $fred = Critter::find("Critter", "Fred"); Critter::display($fred, "Height", "Weight");
What exactly is the difference, leaving aside error checking to make sure the first parameter is a blessed object or a valid class name? E.g. why is it mostly but not exactly the same?
Say Critter is a subclass that doesn’t define
findordisplay—or both! The correspondence isn’t one-for-one because hardwired sub calls don’t perform method lookup, as the perlobj documentation explains.With a sub, you have to know exactly where it is statically, or your program will
die. To call a method, you need only specify where to begin searching for it.For example:
Output: