"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
This syntax:
... only works in Perl 5.14 and above. In earlier versions of Perl, you'll need a semicolon before the block...
Though it is in my experience more conventional to put the package declaration inside the block itself:
Update: as per AnomalousMonk's post below, this latter style has the added advantage that the package declaration itself is lexically scoped, so after perl parses the closing curly brace it puts you back into the main package. I knew that already really. ;-) The new Perl 5.14 syntax also does this, but the middle example does not.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In reply to Re^4: Is this a bug in Perl scope?
by tobyink
|
|