Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^4: Perl allows package names consisting entirely of colons

by tobyink (Abbot)
on Nov 27, 2012 at 16:30 UTC ( #1005879=note: print w/replies, xml ) Need Help??

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'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005879]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2016-10-24 03:03 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (302 votes). Check out past polls.