package Physics::Solar::VSO::Config; use strict; use warnings; our $VERSION = 1.01_04; require Exporter; our @ISA = qw(Exporter); our @EXPORT = (); # @EXPORT_OK is below. use XML::Simple; my $parserOptions = { cache => [ 'memshare' ], NoAttr => 1, SuppressEmpty => undef, }; ( my $configFile = __FILE__ ) =~ s/\.pm$/.xml/; my $config ||= XMLin( $configFile, %$parserOptions ); our %CONFIG : unique = ( %{ $config->{'CONFIG'} || {} } ); sub AUTOLOAD { (my $constant = our $AUTOLOAD) =~ s/^.*://; no strict 'refs'; if (exists($CONFIG{$constant})) { *{$AUTOLOAD} = sub { return $CONFIG{$constant} }; return &{$AUTOLOAD}; } else { require Carp; Carp::croak "Unknown constant : $constant"; } } @Physics::Solar::VSO::Config::EXPORT_OK = ( keys %CONFIG );