X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=lib%2FConfig%2FAny.pm;h=d7749116c771b5d6c5bfa874786a31021bb40ccf;hp=1b056e19103a9249872db63018e2cad3e3fb98c9;hb=aa7bd7c30e544ebbb418c2a0508523800e790836;hpb=11501cf7c7fd46e8723c2de165a00e2f8deefc72 diff --git a/lib/Config/Any.pm b/lib/Config/Any.pm index 1b056e1..d774911 100644 --- a/lib/Config/Any.pm +++ b/lib/Config/Any.pm @@ -49,6 +49,7 @@ configuration formats. Config::Any->load_files( { files => \@files } ); Config::Any->load_files( { files => \@files, filter => \&filter } ); Config::Any->load_files( { files => \@files, use_ext => 1 } ); + Config::Any->load_files( { files => \@files, flatten_to_hash => 1 } ); C attempts to load configuration from the list of files passed in the C parameter, if the file exists. @@ -65,6 +66,9 @@ be aware that you will lose flexibility -- for example, a file called C or C would be. +When the C parameter is defined, the loader will return a hash +keyed on the file names, as opposed to the usual list of single-key hashes. + C also supports a 'force_plugins' parameter, whose value should be an arrayref of plugin names like C. Its intended use is to allow the use of a non-standard file extension while forcing it to be offered to a particular parser. @@ -95,6 +99,7 @@ sub load_files { Config::Any->load_stems( { stems => \@stems } ); Config::Any->load_stems( { stems => \@stems, filter => \&filter } ); Config::Any->load_stems( { stems => \@stems, use_ext => 1 } ); + Config::Any->load_stems( { stems => \@stems, flatten_to_hash => 1 } ); C attempts to load configuration from a list of files which it generates by combining the filename stems list passed in the C parameter with the @@ -193,6 +198,11 @@ sub _load { } } + if ( defined $args->{ flatten_to_hash } ) { + my %flattened = map { %$_ } @results; + return \%flattened; + } + return \@results; }