use XML::Simple; my $parserOptions = { cache => [ 'memshare' ], NoAttr => 1, SuppressEmpty => undef, }; require Exporter; our @ISA = qw(Exporter); our @EXPORT = (); ( my $configFile = __FILE__ ) =~ s/\.pm$/.xml/; my $config ||= XMLin( $configFile, %$parserOptions ); our %CONFIG : unique = ( %{ $config->{'CONFIG'} || {} } ); our %C : unique = ( %{ $config->{'C' } || {} } ); our %PERL : unique = ( %{ $config->{'PERL' } || {} } ); our %SHELL : unique = ( %{ $config->{'SHELL' } || {} } ); sub new { my $class = shift; return bless \%CONFIG, ref($class) || $class; } sub AUTOLOAD { (my $constant = our $AUTOLOAD) =~ s/^.*://; no strict 'refs'; if (exists($CONFIG{$constant})) { *{$AUTOLOAD} = sub { return $CONFIG{$constant} }; return &{$AUTOLOAD}; } elsif (exists($PERL{$constant})) { *{$AUTOLOAD} = sub { return $PERL{$constant} }; return &{$AUTOLOAD}; } else { require Carp; Carp::croak "Unknown constant : $constant"; } } # this needs to stay below where %CONFIG and %PERL are populated our @EXPORT_OK = ( keys %CONFIG, keys %PERL );