in reply to About packages and scopes
You asked if all package variables are global. According to my Perl 5 book, that statement is false.
From what I've read about Perl packages (I'm still also learning it, myself), is that "global" package variables are global to the package, and not neccessarily global to the program.
$PackageName::variablename would be the syntax to access these "global" variables.
Re: Re: About packages and scopes
by nlafferty (Scribe) on Nov 19, 2001 at 22:32 UTC
|
It is possible that i assumed it meant the program when it was the package. But wouldn't that make it lexical? I need a beginners guide to perl packages.
This was from the O'reilly Programming Perl. Upon futher inspection, there are no global variables in perl, just package variables. | [reply] |
|
| [reply] |
|
Wouldn't that make it lexical? Good question.
The answer is no, because lexical variables expire once they are outside a certain scope, and cannot be referenced outside of that scope.
Global package variables on the other hand, can be accessed at any time, as long as you use the package names and colons preceeding the variable name.
Hope that clears up a few things...
| [reply] |
|