This is a question about a perl5 feature I could find no documentation about so far. I would be glad to know whether it is intended this way and safe to use or even recommended.
A bareword ending in a double colon, such as Foo::Bar::, evaluates to a string without the double colon suffix, "Foo::Bar" in this example. Using such a bareword is not prohibited under strict 'subs', but it triggers a warning if perl hasn't seen a package of that name yet.
Example:
use strict; use warnings; package Foo::Bar; package main; my $p = Foo::Bar::; print "$p\n"; # prints Foo::Bar my $q = Baz::Qux::; # warns: # Bareword "Baz::Qux::" refers to nonexistent package print "$q\n"; # prints Baz::Qux
I'll call this feature package-name-quoting, as appending two colons has the effect of quoting plus package name validation. I could use it where package name strings are needed, such as in arguments for isa or DOES. The warning would help me to catch typos.
So, after all, it is a useful feature. Is it documented? I would have expected perlmod to say something about it. Maybe I looked in the wrong place.
In reply to Bareword Package Names by martin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |