What tobyink demonstrated is that a bareword will act as a procedure call if (and only if) a subroutine of that name is known.
Perl's auto-quoting of barewords will only kick in in the absence of such a subroutine.
Any kind of explicit quoting, of course, will also avoid procedure calls.
my $object3 = 'Foo::Bar'->new;
say ref $object3; # says "Foo::Bar"
So we now have established by different examples that trailing double-colons can act like quoting.
There may be caveats though.
In some places where perl looks for barewords, the package-quoted bareword does not seem to lose its bareword-likeness.
use strict;
use warnings;
package Foo::Bar;
package main;
print Foo::Bar::; # warns:
# Name "Foo::Bar" used only once: possible typo
# print() on unopened filehandle Bar
print Foo::Bar::, "Baz\n"; # prints Foo::BarBaz
Perl has to distinguish whether print with a single argument is called as print HANDLE or print LIST, and apparently uses a rather simple heuristic for this.
I try to avoid ambiguity with print and always use the print HANDLE LIST syntax for printing to handles.
|