Make your configuration a global variable instead of a lexical variable and you can access it from anywhere:
package ConfigFileRead; ... use vars qw(%User_Preferences); ...
# main program ... require ConfigFileRead; use Data::Dumper; print Dumper \%ConfigFileRead::User_Preferences;
Or, alternatively, make your subroutine readConfigFile return a reference to the configuration:
# in ConfigRead.pm sub readConfigFile { ... return \%User_Preferences; }; # main program my $config = ConfigFileRead::readConfigFile(); print Dumper $config;
In reply to Re: How to access the values of variables defined in package from main package
by Corion
in thread How to access the values of variables defined in package from main package
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |