use strict;
use warnings;
use configthing qw();
our configthing $cfg = new configthing;
use Data::Dumper;
print Dumper $cfg;
####
package configthing;
use strict;
use warnings;
use fields qw(
a
b
c
d
);
our %DEFAULTS = (
b => 'default for b',
c => 'default for c'
);
1;
sub new {
my $this = shift;
unless (ref $this) {
$this = fields::new($this);
}
our %FIELDS;
foreach my $k ( keys(%FIELDS) ) {
$this->{$k} = '' unless defined($this->{$k});
}
$this->{a} = 'set at initialization';
foreach my $k ( keys(%DEFAULTS) ) {
$this->{$k} = $DEFAULTS{$k};
}
return $this;
}
##
##
$VAR1 = bless( [
bless( {
'c' => 3,
'a' => 1,
'b' => 2,
'd' => 4
}, 'pseudohash' ),
'set at initialization',
'default for b',
'default for c',
''
], 'configthing' );
##
##
$VAR1 = bless( {
'c' => 'default for c',
'a' => 'set at initialization',
'b' => 'default for b',
'd' => ''
}, 'configthing' );