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
## 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
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.
HTH

_________
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
    Thanks for response. I thought about it but, in my mind, it will be more clear to release foregoing code in the various modules, isn't it?
          
    --------------------------------
    SV* sv_bless(SV* sv, HV* stash);
    
      Yes, putting your packages into distinct modules is generally a good way to go as you get compartmentalization and all the sort of thing, and it's pretty much the done thing in the perl community (just look at the code on the CPAN). Usually when you have multiple package declarations, it's for reasons cfreak listed and others.
      HTH

      _________
      broquaint