1vars(3pm) Perl Programmers Reference Guide vars(3pm)
2
3
4
6 vars - Perl pragma to predeclare global variable names
7
9 use vars qw($frob @mung %seen);
10
12 NOTE: For use with variables in the current package for a single scope,
13 the functionality provided by this pragma has been superseded by "our"
14 declarations, available in Perl v5.6.0 or later, and use of this pragma
15 is discouraged. See "our" in perlfunc.
16
17 This pragma will predeclare all the variables whose names are in the
18 list, allowing you to use them under "use strict", and disabling any
19 typo warnings for them.
20
21 Unlike pragmas that affect the $^H hints variable, the "use vars" and
22 "use subs" declarations are not lexically scoped to the block they
23 appear in: they affect the entire package in which they appear. It is
24 not possible to rescind these declarations with "no vars" or "no subs".
25
26 Packages such as the AutoLoader and SelfLoader that delay loading of
27 subroutines within packages can create problems with package lexicals
28 defined using "my()". While the vars pragma cannot duplicate the effect
29 of package lexicals (total transparency outside of the package), it can
30 act as an acceptable substitute by pre-declaring global symbols,
31 ensuring their availability to the later-loaded routines.
32
33 See "Pragmatic Modules" in perlmodlib.
34
35
36
37perl v5.30.2 2020-03-27 vars(3pm)