Ответ 1
Процитировать хроматическое превосходное последнее сообщение в блоге на тему Современный блог в Perl: "Чтобы избежать двусмысленности разбора партитур".
Чтобы проиллюстрировать, почему такой синтаксис полезен, здесь приведен пример из вашего примера:
package a;
our $fh;
use IO::File;
sub s {
return $fh = IO::File->new();
}
package a::s;
sub binmode {
print "BINMODE\n";
}
package main;
a::s->binmode; # does that mean a::s()->binmode ?
# calling sub "s()" from package a;
# and then executing sub "open" of the returned object?
# In other words, equivalent to $obj = a::s(); $obj->binmode();
# Meaning, set the binmode on a newly created IO::File object?
a::s->binmode; # OR, does that mean "a::s"->binmode() ?
# calling sub "binmode()" from package a::s;
# Meaning, print "BINMODE"
a::s::->binmode; # Not ambiguous - we KNOW it the latter option - print "BINMODE"