package Config::File; use 5.000; use strict; use warnings; use Carp; require Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD); @ISA = qw(Exporter); $VERSION = '0.01'; sub new { my $class = shift; my %arg = @_; my $self = {}; bless( $self, $class ); croak($class.'->new() requires file name') unless $arg{file}; $self->{'conf'} = do($arg{file}); return $self; } sub AUTOLOAD { my $self = shift; my $method = $AUTOLOAD; $method =~ s/.*://; unless (defined $self->{'conf'}->{$method}) { croak($method.' not defined in '.$self); } if (ref $self->{'conf'}->{$method} eq 'HASH') { return %{ $self->{'conf'}->{$method} }; } elsif (ref $self->{'conf'}->{$method} eq 'ARRAY') { return @{ $self->{'conf'}->{$method} }; } else { return $self->{'conf'}->{$method}; } } 1;