Home arrow Perl Programming arrow Page 2 - Introduction to mod_perl (part 4): Perl Basics

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.

TABLE OF CONTENTS:
  1. Introduction to mod_perl (part 4): Perl Basics
  2. Using Global Variables and Sharing Them Between Modules/Packages
  3. Making Variables Global With strict Pragma On
  4. Using Exporter.pm to Share Global Variables
  5. Using the Perl Aliasing Feature to Share Global Variables
  6. Using Non-Hardcoded Configuration Module Names
  7. The Scope of the Special Perl Variables
  8. Compiled Regular Expressions
  9. References
By: Stas Bekman
Rating: starstarstarstarstar / 6
January 03, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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.



 
 
>>> More Perl Programming Articles          >>> More By Stas Bekman
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PERL PROGRAMMING ARTICLES

- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: