#!/usr/bin/perl
use strict;
use warnings;
use Auto::Config;
my $root_local = Auto::Config::config->get(root => 'local');
# This line produces the error message
# config->set('root', remote => 'docroot_new');
Auto::Config::config->set('root', remote => 'docroot_new');
print "$root_local\n";
####
package Auto::Config_class;
sub new {
my $class = shift;
my $fn = shift;
my $this = {
root => {
local => 'c:/local',
remote => 'docroot',
},
};
bless $this, $class
}
sub get {
my $this=shift;
my $pri_key = shift;
my $sec_key = shift;
my $default = shift;
exists $this->{$pri_key}{$sec_key} ?
$this->{$pri_key}{$sec_key} :
$default;
}
sub set {
my $this=shift;
my $pri_key = shift;
my $sec_key = shift;
my $value = shift;
$this->{$prim_key}{$sec_key} = $value;
}
1;
####
package Auto::Config;
use strict;
use warnings;
require Exporter;
our @EXPORT=qw(config);
use lib '..';
use Auto::Config_class;
my $config;
sub config {
$config = Auto::Config_class->new('../cwi.ini')
unless defined $config;
$config;
}
1;