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=466033896e80ba1f120beac5f9f7a65ede1fe608;hb=92a04e78451078b33f75e7c44d247b024c27b4f7;hpb=f0e3c2214342d0d8a8839009b8b9c7e6bfbc7ab2 diff --git a/lib/Config/Any/XML.pm b/lib/Config/Any/XML.pm index 4660338..a5fc881 100644 --- a/lib/Config/Any/XML.pm +++ b/lib/Config/Any/XML.pm @@ -42,29 +42,32 @@ Attempts to load C<$file> as an XML file. sub load { my $class = shift; my $file = shift; + my $args = shift || {}; require XML::Simple; - XML::Simple->import; - my $config = 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;