in reply to need some OO help
Just put an empty ("abstract") method in your base class, which your subclasses will use to get the path.
package BaseConf; my $Conf; sub _load_config { my $self = shift; my $conf_file = $self->config_file_path; croak "unable to find $conf_file" unless -e $conf_file and -r $conf_file; $Conf = Config::Tiny->read( $conf_file ); croak "read config file '$conf_file' failed: $Config::Tiny::errstr" unless $Conf; } sub config_file_path { croak "config_file_path must be provided by subclass."; } ... package MyConf; use base 'BaseConf'; sub config_file_path { return '/path/to/conf.file'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: need some OO help
by Qiang (Friar) on Mar 26, 2007 at 19:59 UTC | |
by friedo (Prior) on Mar 26, 2007 at 20:50 UTC | |
by Qiang (Friar) on Mar 26, 2007 at 21:36 UTC |