Subject: | Incorrect parsing of sources if options are passed to a source |
Here's the symptom:
% perl -MConfig::Layered -e "Config::Layered->load_config( sources => [ 'ConfigAny', { file => 't/config' } ] )"
Couldn't find HASH(0xb9fa68) or Config::Layered::Source::HASH(0xb9fa68) at /home/dj/tmp/lib/perl5/Config/Layered.pm line 97.
The problem appears to be in _normalize_sources.
59 sub _normalize_sources {
60 my ( $self, $sources ) = @_;
61
62 my @new_sources;
63 while ( my $source = shift @{$sources} ) {
64 if ( ref @{$self->{sources}}[0] eq 'HASH' ) {
65 push @new_sources, [ $source, shift @{$self->{sources}} ];
66 } else {
67 push @new_sources, [ $source, {} ];
68 }
69 }
70 $self->{sources} = [@new_sources];
71 }
Note that lines 64 & 65 refer to $self->{sources} rather than $sources, which messes things up.