Ricardo Pichler wrote: > > #!/usr/bin/perl > use strict; > $|=0; > use vars qw (%WRRConf %DHCPDConf %IPTablesConf %GeneralConf > %DBIConf %NetworkConf %IfCfgConf %WIPLConf > %WANInitConf %LANInitConf > %NetworkRemoteConf %WRRRemoteConf %DHCPDRemoteConf > %IPTablesRemoteConf %GeneralRemoteConf %SubnetRemoteConf > %AdmNetRemoteConf %VisitorSubnetRemoteConf > %BlockedSubnetRemoteConf %WANRemoteConf > %DCClientsMAC %DCClientsWeight %DCClientsIP > $dbh $Debug > ); > > This file have various includes .pm after these lines, I believe that this lines in > bold, > export the variables declared to modules. This is correct? This is an mode of making > they to becoming "global" to modules? Sorry my bad english.
Hi Ricardo. 'use vars' is very similar to declaring variables with 'our', which has been available since Perl 5.6. In fact at this place in the program the two are identical, and 'our' is preferred for new software. Both forms declare persistent package variables in the current package. Package variables differ from lexical variables in that there is only ever one variable of a given name. In your example, for instance, using hash %WRRConf anywhere in the program will access the same data, even within subroutines and code blocks. This is in contrast with 'my' variables which are created and destroyed as they are required, and are unique to the code block in which they are declared. This has no bearing on the modules that are included, and no exporting is involved (although code in any package could, if it chose, access the data as %main::WRRConf etc.) There really should be a good reason to use package variables like this. It is rarely necessary outside an imported module. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>