start page | rating of books | rating of authors | reviews | copyrights

Programming Perl

Programming PerlSearch this book
Previous: 7.2.75 Time::Local - Efficiently Compute Time from Local and GMT Time Chapter 7
The Standard Perl Library
Next: 8. Other Oddments
 

7.2.76 vars - Predeclare Global Variable Names

use vars qw($frob @mung %seen);

This module predeclares all variables whose names are in the list, allowing you to use them under use strict , and disabling any typo warnings.

Packages such as the AutoLoader and SelfLoader that delay loading of subroutines within packages can create problems with file-scoped lexicals defined using my . This is because they move the subroutines outside the scope of the lexical variables. While the use vars pragma cannot duplicate the effect of file-scoped lexicals (total transparency outside of the file), it can act as an acceptable substitute by pre-declaring global symbols, ensuring their availability to the routines whose loading was delayed.

See also the subs module.


Previous: 7.2.75 Time::Local - Efficiently Compute Time from Local and GMT Time Programming Perl Next: 8. Other Oddments
7.2.75 Time::Local - Efficiently Compute Time from Local and GMT Time Book Index 8. Other Oddments