--- Nick Transier <[EMAIL PROTECTED]> wrote:
> Does the C++ notion of private data have a similar structure in perl,
> when defining packages, I find that when I try to define global
> variables inside the package, but outside of all the subroutines, I
> get a million errors. 

If you need private class data, define it in the package with my().
Methods will still be able to access it, but it doesn't exist outside
the scope of the file in which it was defined.

Just be aware that package and scope are *N*O*T* the same thing. In
fact, they aren't even related. They're neighbors that say "Good
morning, Ralph" as they head out to work, but that's about it. =o)

That means you can define several packages in a file, all of which can
use the same file-scoped lexicals, but you can also put methods in
another file that go into the same package, but will not be able to get
to the file-scoped lexicals.

If you want the scope of a lexical limited to one package in a file,
wrap brackets around that package. If you need for it to be accessed
from other files, you'll probably want to make it a true package
global, but prefix the name with an underscore ($pack::_var) to tell
other coders to keep their hands off it. =o)

__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/

Reply via email to