in reply to Using a package into script
Please, tell me, does it have a sense and, if yes, when?Sure, for each package declaration the rest of the lexical scope, or until another package declaration, will be in the given package's namespace. So sub one will live in One::one e.g
This sort of thing is useful when you want to hide packages/classes (e.g under the hood tie implementations) and saves on fully declaring everything (without a package declartion sub one would have to be declared as sub One::one). See. package for more info on it's behaviour.## default namespace is 'main' { package One; sub one { print "I am in ", __PACKAGE__, $/ } } ## namespace back to main as lexical scope has ended One::one(); __output__ I am in One
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using a package into script
by nite_man (Deacon) on May 07, 2003 at 13:49 UTC | |
by broquaint (Abbot) on May 07, 2003 at 14:01 UTC |