Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

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


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

In terms of the package keyword itself, :: and main are distinct packages, and :::: is another package entirely...

$ perl -Mstrict -Mwarnings -E'package main; say __PACKAGE__' main $ perl -Mstrict -Mwarnings -E'package ::main; say __PACKAGE__' main $ perl -Mstrict -Mwarnings -E'package ::; say __PACKAGE__' :: $ perl -Mstrict -Mwarnings -E'package ::::; say __PACKAGE__' ::::
{ package main; sub xxx { 0 }; package ::; sub xxx { 1 }; package ::::; sub xxx { 2 }; } use 5.010; say ::xxx(); # 0 say ::::xxx(); # 1 say ::::::xxx(); # 2
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re^2: Perl allows package names consisting entirely of colons
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-08-02 00:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls