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'; }
In reply to Re: need some OO help
by friedo
in thread need some OO help
by Qiang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |