X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=lib%2FConfig%2FAny%2FXML.pm;h=a5fc8819bfd5efc1d7464f25620fea9169b04a79;hp=d5221c5accc1b88f50fb944c7229f2fbacddb1c5;hb=92a04e78451078b33f75e7c44d247b024c27b4f7;hpb=e23825ecd2eaaeba8d95b59317a5b78f3c4924bf diff --git a/lib/Config/Any/XML.pm b/lib/Config/Any/XML.pm index d5221c5..a5fc881 100644 --- a/lib/Config/Any/XML.pm +++ b/lib/Config/Any/XML.pm @@ -45,27 +45,29 @@ sub load { my $args = shift || {}; require XML::Simple; - my $config = XML::Simple::XMLin( - $file, + my $config = XML::Simple::XMLin( + $file, ForceArray => [ qw( component model view controller ) ], %$args ); - return $class->_coerce($config); + return $class->_coerce( $config ); } sub _coerce { + # coerce the XML-parsed config into the correct format - my $class = shift; + my $class = shift; my $config = shift; my $out; - for my $k (keys %$config) { - my $ref = $config->{$k}; - my $name = ref $ref ? delete $ref->{name} : undef; - if (defined $name) { - $out->{$k}->{$name} = $ref; - } else { - $out->{$k} = $ref; + for my $k ( keys %$config ) { + my $ref = $config->{ $k }; + my $name = ref $ref ? delete $ref->{ name } : undef; + if ( defined $name ) { + $out->{ $k }->{ $name } = $ref; + } + else { + $out->{ $k } = $ref; } } $out;