Skip to content

Commit 5abea43

Browse files
committed
Improvements in variable resolving
1 parent e5ce42d commit 5abea43

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Changes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ Revision history for Perl extension Config::Processor.
3535

3636
0.02 Wed Apr 27 11:55:00 MSK 2016
3737
- Initial release.
38-

README

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Config-Processor version 0.21_01
1+
Config-Processor version 0.21_02
22
=============================
33

44
INSTALLATION
@@ -29,4 +29,3 @@ All rights reserved.
2929

3030
This module is free software; you can redistribute it and/or modify it under
3131
the same terms as Perl itself.
32-

lib/Config/Processor.pm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use 5.008000;
44
use strict;
55
use warnings;
66

7-
our $VERSION = '0.21_01';
7+
our $VERSION = '0.21_02';
88

99
use File::Spec;
1010
use YAML::XS qw( LoadFile );
@@ -284,7 +284,7 @@ sub _resolve_var {
284284
my $ancs = shift;
285285

286286
if ( $name =~ m/^\./ ) {
287-
my @tokens = split( /\./, $name );
287+
my @tokens = split( /\./, $name, -1 );
288288
my $anc_index = -1;
289289

290290
while (1) {
@@ -295,6 +295,9 @@ sub _resolve_var {
295295
last if length($token) > 0;
296296

297297
shift @tokens;
298+
299+
last unless @tokens;
300+
298301
$anc_index++;
299302
}
300303

@@ -315,7 +318,7 @@ sub _resolve_var {
315318
my $vars = $self->{_vars};
316319

317320
unless ( defined $vars->{$name} ) {
318-
my @tokens = split( /\./, $name );
321+
my @tokens = split( /\./, $name, -1 );
319322

320323
my $value = eval {
321324
$self->_fetch_value( $self->{_config}, \@tokens, $ancs );
@@ -339,6 +342,10 @@ sub _fetch_value {
339342
my $tokens = shift;
340343
my $ancs = shift;
341344

345+
unless ( @{$tokens} ) {
346+
return $node;
347+
}
348+
342349
my $value;
343350
my @anc_stack = @{$ancs};
344351

0 commit comments

Comments
 (0)