<?xml version="1.0" encoding="windows-1252"?>
<node id="1005879" title="Re^4: Perl allows package names consisting entirely of colons" created="2012-11-27 11:30:52" updated="2012-11-27 11:30:52">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;"why disallow it?"&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I never meant to imply that it &lt;em&gt;should&lt;/em&gt; 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.&lt;/p&gt;
&lt;p&gt;Why disallow &lt;c&gt;package 123&lt;/c&gt; and &lt;c&gt;package 123::&lt;/c&gt; but allow &lt;c&gt;package ::123&lt;/c&gt;? The tokens allowed to follow &lt;c&gt;package&lt;/c&gt; are have interesting but seemingly arbitrary restrictions, which have nothing to do with what names are actually usable for naming functions, variables, etc...&lt;/p&gt;
&lt;code&gt;
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.
&amp;{"123  :::x"};
&lt;/code&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1005846</field>
<field name="parent_node">
1005867</field>
</data>
</node>
