vars::i - Perl pragma to declare and simultaneously initialize global variables.
use Data::Dumper; $Data::Dumper::Deparse = 1; # use vars::i '$VERSION' => 3.44; use vars::i '@BORG' => 6 .. 6; use vars::i '%BORD' => 1 .. 10; use vars::i '&VERSION' => sub(){rand 20}; use vars::i '*SOUTH' => *STDOUT; # BEGIN { print SOUTH Dumper [ $VERSION, \@BORG, \%BORD, \&VERSION ]; } # use vars::i [ # has the same affect as the 5 use statements above '$VERSION' => 3.66, '@BORG' => [6 .. 6], '%BORD' => {1 .. 10}, '&VERSION' => sub(){rand 20}, '*SOUTH' => *STDOUT, ]; # print SOUTH Dumper [ $VERSION, \@BORG, \%BORD, \&VERSION ]; # __END__
For whatever reason, I once had to write something like
BEGIN { use vars '$VERSION'; $VERSION = 3; }
and I really didn't like typing that much.
Also, I like being able to say
use vars::i '$VERSION' => sprintf("%d.%02d", q$Revision: 1.3 $ =~ /: (\d+)\.(\d+)/); use vars::i [ '$VERSION' => sprintf("%d.%02d", q$Revision: 1.3 $ =~ /: (\d+)\.(\d+)/), '$REVISION'=> '$Id: GENERIC.pm,v 1.3 2002/06/02 11:12:38 _ Exp $', ];
Like with use vars;, there is no need to fully qualify the variable name.
use vars;
See vars, "our" in perldoc, "Pragmatic Modules" in perlmodlib.
1 POD Error
The following errors were encountered while parsing the POD:
'=end FOR LATER ON CPAN' is invalid. (Stack: =begin FOR)
To install vars::i, copy and paste the appropriate command in to your terminal.
cpanm
cpanm vars::i
CPAN shell
perl -MCPAN -e shell install vars::i
For more information on module installation, please visit the detailed CPAN module installation guide.