aboutsummaryrefslogtreecommitdiff
path: root/lib/Config/Parser.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Config/Parser.pm')
-rw-r--r--lib/Config/Parser.pm33
1 files changed, 13 insertions, 20 deletions
diff --git a/lib/Config/Parser.pm b/lib/Config/Parser.pm
index 6ca5bf7..ca2fcce 100644
--- a/lib/Config/Parser.pm
+++ b/lib/Config/Parser.pm
@@ -5,7 +5,7 @@ use parent 'Config::AST';
use Carp;
use Cwd qw(abs_path);
use Text::ParseWords;
-use Class::Inspector;
+use mro;
our $VERSION = "1.01";
@@ -30,11 +30,12 @@ sub new {
$self->lexicon($lex);
} else {
$self->lexicon({ '*' => '*' });
- my $subs = Class::Inspector->subclasses(__PACKAGE__);
+ my @cl = grep { $_ ne __PACKAGE__ && $_->isa(__PACKAGE__) }
+ reverse @{mro::get_linear_isa($class)};
my $dict;
- if ($subs) {
- foreach my $c (@$subs) {
- if (my ($file, $line, $data) = findsynt($c)) {
+ if (@cl) {
+ foreach my $c (@cl) {
+ if (my ($file, $line, $data) = $c->findsynt) {
my $d = $self->loadsynt($file, $line, $data);
if ($d) {
$dict = { %{$dict // {}}, %$d }
@@ -70,21 +71,13 @@ sub findsynt {
my $file = $class;
$file =~ s{::}{/}g;
$file .= '.pm';
- # Normally each loaded file has a corresponding entry in %INC. However,
- # in perl 5.16.3 and below, a call to Class::Inspector->subclasses
- # for Config::Parser::Package returns, among real classes the "class"
- # Config::Parser::SUPER, which is apparently an alias to Config::Parser,
- # except that it satisfies the isa('Config::Parser::Package') check and
- # is not listed in %INC. The exists check below helps eliminate it.
- if (exists($INC{$file})) {
- $file = abs_path($INC{$file})
- or croak "can't find module file for $class";
- local ($/, *FILE);
- open FILE, $file or croak "Can't open $file";
- my ($text, $data) = split /(?m)^__DATA__$/, <FILE>, 2;
- close FILE;
- return ($file, 1+($text =~ tr/\n//), $data) if $data;
- }
+ $file = abs_path($INC{$file})
+ or croak "can't find module file for $class";
+ local ($/, *FILE);
+ open FILE, $file or croak "Can't open $file";
+ my ($text, $data) = split /(?m)^__DATA__$/, <FILE>, 2;
+ close FILE;
+ return ($file, 1+($text =~ tr/\n//), $data) if $data;
return ();
}

Return to:

Send suggestions and report system problems to the System administrator.