5 vars - Perl pragma to predeclare global variable names
9 use vars qw($frob @mung %seen);
13 This will predeclare all the variables whose names are
14 in the list, allowing you to use them under "use strict", and
15 disabling any typo warnings.
17 See L<perlmod/Pragmatic Modules>.
24 my $callpack = caller;
25 my ($pack, @imports, $sym, $ch) = @_;
26 foreach $sym (@imports) {
27 croak "Can't declare another package's variables" if $sym =~ /::/;
28 ($ch, $sym) = unpack('a1a*', $sym);
29 *{"${callpack}::$sym"} =
30 ( $ch eq "\$" ? \$ {"${callpack}::$sym"}
31 : $ch eq "\@" ? \@ {"${callpack}::$sym"}
32 : $ch eq "\%" ? \% {"${callpack}::$sym"}
33 : $ch eq "\*" ? \* {"${callpack}::$sym"}
34 : $ch eq "\&" ? \& {"${callpack}::$sym"}
35 : croak "'$ch$sym' is not a valid variable name\n");