From fc1f20c698a9f29364ffda8358d3639a2f587462 Mon Sep 17 00:00:00 2001 From: Gerhard Gonter <ggonter@gmail.com> Date: Sat, 9 Jul 2022 07:37:40 +0200 Subject: [PATCH] Multiple attributes (of logical devices) are rearranged into an array reference when the second attribute with the same name is encountered. Apparently, it is possible to have zero or even more than one physical device as "Dedicated Hot-Spare", as documented in [1]. Maybe this is the only attribute that can have multiple occurances. This modification now records multiple occurances as an array reference. * [1] https://github.com/kumy/Parse-Arcconf/issues/4 --- lib/Parse/Arcconf.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Parse/Arcconf.pm b/lib/Parse/Arcconf.pm index cc73f7e..db594fc 100644 --- a/lib/Parse/Arcconf.pm +++ b/lib/Parse/Arcconf.pm @@ -206,7 +206,15 @@ sub parse_config_fh } elsif ($line =~ /^\s+([^:]+)\s+:\s+(.*)$/) { my ($an, $av)= ($1, $2); $an=~ s/\s*$//; - $ctrl->{'logical drive'}{$current_logical_drive}{$an} = $av; + if (exists($ctrl->{'logical drive'}{$current_logical_drive}{$an})) { + if (ref ($ctrl->{'logical drive'}{$current_logical_drive}{$an}) eq 'ARRAY') { + push (@{$ctrl->{'logical drive'}{$current_logical_drive}{$an}} => $av); + } else { + $ctrl->{'logical drive'}{$current_logical_drive}{$an} = [$ctrl->{'logical drive'}{$current_logical_drive}{$an}, $av]; + } + } else { + $ctrl->{'logical drive'}{$current_logical_drive}{$an} = $av; + } } elsif ($line =~ /^\s+-+$/) { my $cat = <$fh>; $cat =~ s/^\s+(\S.*\S+)\s+/$1/; -- GitLab