http://www.perlmonks.org?node_id=1005879


in reply to Re^3: Perl allows package names consisting entirely of colons
in thread Perl allows package names consisting entirely of colons

"why disallow it?"

I never meant to imply that it should be disallowed. I was just expressing surprise that it is not disallowed, given that Perl does place limits on what tokens may appear in a package declaration.

Why disallow package 123 and package 123:: but allow package ::123? The tokens allowed to follow package are have interesting but seemingly arbitrary restrictions, which have nothing to do with what names are actually usable for naming functions, variables, etc...

use 5.010; use strict qw( vars subs ); use warnings; # Package name contains whitespace; sub name begins with leading colon +. *{"123 :::x"} = sub { say "hello" }; # Yet it can be called. &{"123 :::x"};
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'