in reply to Using config::any

This works, but I'd suggest looking for a better way:
use strict; use warnings; use Config::Any; my @files = ("test.cfg.ini");# $files[0]="C:\\wamp\\www\\password.ini" +; my $cfg = Config::Any->load_files({files =>\@files,use_ext => 1 }); for my $c (@$cfg){ for my $f (keys %$c){ print "File $f has the following :\n"; for my $section(keys %{$c->{$f}}){ print " in Section $section:\n"; for my $k2 (keys %{$c->{$f}{$section}}){ print "\t$k2=" . $c->{$f}{$section}{$k2} . "\n"; } } } } }
If you wanted to hard-code it, you could write:
print $cfg->[0]{'test.cfg.ini'}{password}{password} . "\n"; # prints +'mypass'

             I hope life isn't a big joke, because I don't get it.
                   -SNL

Replies are listed 'Best First'.
Re^2: Using config::any
by ItsyBitsy (Novice) on May 31, 2012 at 03:16 UTC
    I used the following code(hard coded)
    use strict; use warnings; use Config::Any; my @files = ("C:\\wamp\\password.ini"); my $cfg = Config::Any->load_files({files =>\@files,use_ext => 1 }); print $cfg->[0]{'password.ini'}{password}{password} . "\n"; # prints
    However it throws an error saying
    Use of uninitialized value in concatenation (.) or string at caller.pl + line 39.
      You can use the for-loops in my earlier message to figure out what it is expecting, but I suspect it is something like this:
      print $cfg->[0]{"C:\\wamp\\password.ini"}{password}{password} . "\n" +; #

                   I hope life isn't a big joke, because I don't get it.
                         -SNL

        That worked. Thanks.