Even though many people will say "the package declaration" or the "our declaration" in conversation IMHO they arent declarations at all. They dont "create" in the sense that the my or sub declarations do.
To be niggly, they both do create things. Consider:
use strict; use warnings; print 'before package Foo ', exists($main::{'Foo::'}) ? "exists" : "doesn't exist", "\n"; eval q{ package Foo }; print 'after package Foo ', exists($main::{'Foo::'}) ? "exists" : "doesn't exist", "\n"; print 'before our Bar ', exists($main::{Bar}) ? "exists" : "doesn't exist", "\n"; eval q{ our $Bar =99}; print 'after our Bar ', exists($main::{Bar}) ? "exists" : "doesn't exist", "\n"; __END__ # produces before package Foo doesn't exist after package Foo exists before our Bar doesn't exist after our Bar exists
A package statement create a symbol table hash if one doesn't already exist. An our statement creates a symbol table entry if one doesn't already exist.
While the scoping rules for our and package are different from my they still "declare" something so it makes sense to me :-)
In reply to Re: On Declaration
by adrianh
in thread On Declaration
by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |