Introduction to mod_perl (part 4): Perl Basics - Making Variables Global With strict Pragma On (Page 3 of 9 )
First you use :
use strict;
Then you use:
use vars qw($scalar %hash @array);
This declares the named variables as package globals in the currentpackage. They may be referred to within the same file and packagewith their unqualified names; and in different files/packages withtheir fully qualified names.
With perl5.6 you can use the our operator instead:
our qw($scalar %hash @array);
If you want to share package global variables between packages, hereis what you can do.
Next: Using Exporter.pm to Share Global Variables >>
More Perl Articles
More By Stas Bekman