ConfigReader
view release on metacpan or search on metacpan
You can specify the package in which to create the subroutines with the
optional $package argument. You may also specify which configuration
directives to create accessor subroutines for. By default,
subroutines will be created for all the directives.
=cut
sub define_accessors {
my ($self, $package, @names) = @_;
@names = $self->directives() unless @names;
$package = (caller)[0] unless defined $package;
my $name;
foreach $name (@names) {
$self->_define_accessor($name, $package);
}
@names;
}
sub _define_accessor {
my ($self, $name, $package) = @_;
$package = (caller)[0] unless defined $package;
no strict 'refs';
*{ $package . "::" . $name } = $self->_make_accessor($name);
return $name;
}
sub _make_accessor {
my ($self, $name) = @_;
return sub {
my ($package, $filename, $line) = caller;
( run in 1.723 second using v1.01-cache-2.11-cpan-1e74a51a04c )