swizzly has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I need help with the IncludeDirectories option of Config::General module. I wrote following little code to try out:
#!/usr/bin/perl -w use strict; use Readonly; use Config::General; use Data::Dumper; Readonly my $config_dir => "/home/user/workspace/cfgtest/etc"; my $config = Config::General->new( -IncludeDirectories => 1, -ConfigFile => $config_dir); my %conf = $config->getall;
I also created a small config file under /home/user/workspace/cfgtest/etc/config.cfg with a single entry:
 EXCLUDE whatever
It works, %conf contains the options from the .cfg file, but it also generates the following error message:

"Use of uninitialized value $file in concatenation (.) or string at /usr/lib64/perl5/vendor_perl/File/Spec/Unix.pm line 102"

I've already chewed through the manual several times, also searched the net for examples, but no luck. Any idea how to fix it, what is the right way to use IncludeDirectories option?

Replies are listed 'Best First'.
Re: Config::General -IncludeDirectories usage
by haukex (Archbishop) on Sep 08, 2021 at 09:34 UTC

    I believe you've discovered a bug in Config::General. On line 519, it says:

    my @files = sort grep { -f catfile($configfile, $_) } catfile($configf +ile, $_), readdir INCLUDEDIR;

    And the extra catfile($configfile, $_), doesn't make sense to me. I think the line should be:

    my @files = sort grep { -f catfile($configfile, $_) } readdir INCLUDED +IR;

    You should probably file a bug report, but note the module hasn't had a release in about 5 years, so you'll have to decide whether you might want to patch the module yourself.

    Update: Thanks for reporting it as RT#139261