summaryrefslogtreecommitdiffabout
path: root/lib/Config/Parser.pm
Side-by-side diff
Diffstat (limited to 'lib/Config/Parser.pm') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/Config/Parser.pm29
1 files changed, 18 insertions, 11 deletions
diff --git a/lib/Config/Parser.pm b/lib/Config/Parser.pm
index 17a3cd0..6ca5bf7 100644
--- a/lib/Config/Parser.pm
+++ b/lib/Config/Parser.pm
@@ -7,7 +7,7 @@ use Cwd qw(abs_path);
use Text::ParseWords;
use Class::Inspector;
-our $VERSION = "1.00";
+our $VERSION = "1.01";
sub new {
my $class = shift;
@@ -34,7 +34,7 @@ sub new {
my $dict;
if ($subs) {
foreach my $c (@$subs) {
- if (my ($file, $line, $data) = $c->findsynt) {
+ if (my ($file, $line, $data) = findsynt($c)) {
my $d = $self->loadsynt($file, $line, $data);
if ($d) {
$dict = { %{$dict // {}}, %$d }
@@ -70,15 +70,22 @@ sub findsynt {
my $file = $class;
$file =~ s{::}{/}g;
$file .= '.pm';
- $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 () unless $data;
- return ($file, 1+($text =~ tr/\n//), $data);
+ # 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;
+ }
+ return ();
}
sub loadsynt {

Return to:

Send suggestions and report system problems to the System administrator.