in reply to Re^6: How not to use "our"?
in thread How not to use "our"?

Whether you can have, or cannot have, package variables is unrelated to whether the package variables are scalars or hashes, or whether they are exported or not.

Note also that if mod_perl means you cannot have globals, it would mean you cannot have Perl. Certain global variables always exist.

The issue with mod_perl is that modules get only compiled "once" (well, typically, once in the life time of an Apache child), and not each time the program is run. This means "globals" may not get (re)initialized. But that is not the same as package variables!. File scoped lexicals and sub-bounded state variables won't get (re)initialized either. And package variables that get initialized in your mod_perl program do get initialized.

The mod_perl issue all has to do when certain code is run - not whether variables are package variables or lexicals.

Replies are listed 'Best First'.
Re^8: How not to use "our"?
by Anonymous Monk on Nov 30, 2010 at 15:51 UTC

    Thanks for above, JavaFan!

    I'm trying to grasp the concept before I use mod_perl, so please bear with me if my questions sounded silly.

    I'm trying to make sense of 'The issue with mod_perl is that modules get only compiled "once"'. Let's say I've a variable (my $score) in a module that stores the score of a user, say, playing a game. When another user comes online, or for that matter, when several users appear, will the variable correctly store the value for each of the user when the script (that calls the said module) is run?

      How should I know? As I said, it all depends on when you assign to $score, and what its scope is.