51 |
), |
), |
52 |
q( |
q( |
53 |
if ($in =~ s/^\s*(\S+)\s+(.*)\s*$//) { |
if ($in =~ s/^\s*(\S+)\s+(.*)\s*$//) { |
54 |
$atom->{type} = 'KEY_VALUE'; |
$atom->{type} = 'KEY_LIST'; |
55 |
$atom->{key} = $1; |
$atom->{key} = $1; |
56 |
$atom->{value} = [split(/\s*,\s*/, $2)]; |
$atom->{list} = [split(/\s*,\s*/, $2)]; |
57 |
$atom->{sections} = [ @{$out->{current_sections}} ]; |
$atom->{sections} = [ @{$out->{current_sections}} ]; |
58 |
$matched = 1; |
$matched = 1; |
59 |
} |
} |
61 |
], |
], |
62 |
comments => [ ['#'] ], |
comments => [ ['#'] ], |
63 |
output => { |
output => { |
64 |
KEY_VALUE => q( |
KEY_LIST => q( |
65 |
my ($key, $value) = ($atom->{key}, join(', ', @{$atom->{value}})); |
my ($key, $value) = ($atom->{key}, join(', ', @{$atom->{list}})); |
66 |
$output_indentation = $out->{current_indentation} ||= 1; |
$output_indentation = $out->{current_indentation} ||= 1; |
67 |
$output_text = qq($key $value); |
$output_text = qq($key $value); |
68 |
), |
), |
88 |
} |
} |
89 |
@{@{$out->{atoms}}[$index]}{keys(%args)} = values(%args) |
@{@{$out->{atoms}}[$index]}{keys(%args)} = values(%args) |
90 |
), |
), |
91 |
|
find_atom_pos => q( |
92 |
|
$first_atom ||= 0; |
93 |
|
$last_atom ||= @{$out->{atoms}}-1; |
94 |
|
my @res; |
95 |
|
foreach my $pos ($first_atom..$last_atom) { |
96 |
|
my $atom = $out->{atoms}->[$pos]; |
97 |
|
my $flag = 1; |
98 |
|
foreach (keys(%args)) { |
99 |
|
if ($_ eq 'sections') { |
100 |
|
$atom->{sections}[0]{name} eq $args{sections}->[0]{name} or $flag = 0; |
101 |
|
} elsif ($_ eq 'list') { |
102 |
|
foreach my $i (0..@{$args{$_}}-1) { |
103 |
|
$atom->{$_}->[$i] eq $args{$_}->[$i] or $flag = 0; |
104 |
|
} |
105 |
|
} else { |
106 |
|
$atom->{$_} eq $args{$_} or $flag = 0; |
107 |
|
} |
108 |
|
} |
109 |
|
$flag and push(@res, $pos); |
110 |
|
} |
111 |
|
wantarray ? @res : $res[-1]; |
112 |
|
), |
113 |
}; |
}; |
114 |
|
|
115 |
1 |
1 |