http://www.perlmonks.org?node_id=1038492
Clovis_Sangrail has asked for the wisdom of the Perl Monks concerning the following question:

I am going thru the Alpaca book, currently trying out the examples of objects/instances. The packages (or classes) defined in the text are typically written as:

{ package somename; #perlcode }

I'm used to seeing things analagous to the 'package' keyword (ex 'sub') outside of the block of code. I find that Perl (or my example programs, at any rate) run identically with the syntax of the packages written as above (from the textbook) or in any of the following ways:

package somename; { #perlcode } package somename { #perlcode } package somename { #perlcode }; { package somename; #perlcode };

I do get syntax errors with the following:

{ package somename #perlcode }

When the package keyword is inside the block it seems you have to have a semicolon after the package/class name. But I am surprised that so many other variations all work. My question is, am I introducing some kind of subtle difference in scope or something like that? Are they really all the same?