wfsp has asked for the wisdom of the Perl Monks concerning the following question:
After addingpackage my::data; use strict; use warnings; my $Config ={ # this would be loaded from a config.ini file root => { local => 'c:/local', remote => 'docroot', }, category => { europe => 'europe.html', women => 'women.html', }, }; sub Config{ if (@_ == 4){ $Config->{$_[1]}{$_[2]} = $_[3]; return $_[3]; } elsif (@_ == 3){ if (exists $Config->{$_[1]}{$_[2]}){ return $Config->{$_[1]}{$_[2]}; } else{ return; } } else{ return; } } 1;
to any module $Config can then be accessed:use my::data;
or changed:$data = my::data->Config('root', 'local');
my::data->Config('root', 'local' => 'c:/local_path');
Is this "a way to do it"? Or is it just madness?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using "Class Data as Package Variables" to hold a global
by salva (Canon) on Apr 30, 2005 at 15:07 UTC | |
by Forsaken (Friar) on Apr 30, 2005 at 15:14 UTC | |
by salva (Canon) on Apr 30, 2005 at 15:25 UTC | |
by wfsp (Abbot) on Apr 30, 2005 at 17:14 UTC | |
by salva (Canon) on Apr 30, 2005 at 17:59 UTC | |
by wfsp (Abbot) on Apr 30, 2005 at 18:04 UTC | |
by salva (Canon) on Apr 30, 2005 at 19:40 UTC | |
|
Re: Using "Class Data as Package Variables" to hold a global
by brian_d_foy (Abbot) on Apr 30, 2005 at 17:21 UTC |