Using Global Variables and Sharing Them Between Modules/Packages - Perl
Now that you have mod_perl installed, you can move on to learning how to use it. This article will run you through some basic Perl concepts to start with.
It helps when you code your application in a structured way, using theperl packages, but as you probably know once you start using packagesit's much harder to share the variables between the variouspackagings. A configuration package comes to mind as a good example ofthe package that will want its variables to be accessible from theother modules.
Of course using the Object Oriented (OO) programming is the best wayto provide an access to variables through the access methods. But ifyou are not yet ready for OO techniques you can still benefit fromusing the techniques I'm going to talk about.
Making Variables Global
When you first wrote $x in your code you created a (package) globalvariable. It is visible everywhere in your program, although if usedin a package other than the package in which it was declared(main:: by default), it must be referred to with its fullyqualified name, unless you have imported this variable withimport(). This will work only if you do not use strict pragma; butit's very important to use this pragma if you want to run your scriptsunder mod_perl.