here is another one
=head2 Global vs. Fully Qualified Variables
It's always a good idea to avoid using global variables where it's
possible. Some variables must be either global, such as C<@ISA> or
else fully qualified such as C<@MyModule::ISA>, so that Perl can see
them from different packages.
A combination of C<strict> and C<vars> pragmas keeps modules clean and
reduces a bit of noise. However, the C<vars> pragma also creates
aliases, as does C<Exporter>, which eat up more memory. When
possible, try to use fully qualified names instead of C<use vars>.
For example write:
package MyPackage1;
use strict;
@MyPackage1::ISA = qw(CGI);
$MyPackage1::VERSION = "1.00";
1;
instead of:
package MyPackage2;
use strict;
use vars qw(@ISA $VERSION);
@ISA = qw(CGI);
$VERSION = "1.00";
1;
Here are the numbers under Perl version 5.6.0
% perl -MGTop -MMyPackage1 -le 'print GTop->new->proc_mem($$)->size'
1908736
% perl -MGTop -MMyPackage2 -le 'print GTop->new->proc_mem($$)->size'
2031616
We have a difference of 122880 bytes!
Note that Perl 5.6.0 introduced a new our() pragma which works like
my() scope-wise, but declares global variables.
package MyPackage3;
use strict;
our @ISA = qw(CGI);
our $VERSION = "1.00";
1;
which uses the same amount of memory as a fully qualified global
variable:
% perl -MGTop -MMyPackage3 -le 'print GTop->new->proc_mem($$)->size'
1908736
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/