in reply to perl: Config::Simple config file reading

UPDATE: You also cross-posted this question on Stackoverflow. It's good form to mention that and provide a link.

There are problems with your code. You should always use strict; at the top of all your code and let Perl find some of your errors for free.

But besides that you are using a module that doesn't return the data in the way you want. You should use Config::Tiny which is only for ini-style files, and returns a reference to a hash structure as you want:

#! perl -w use strict; use feature qw/ say /; use Config::Tiny; my $cfg = Config::Tiny->new; $cfg = Config::Tiny->read('new.conf') or die $!; foreach my $section (sort keys %{ $cfg }) { say "section: $section"; foreach my $param (sort keys %{ $cfg->{ $section } }) { say "$section.$param : $cfg->{ $section }->{ $param }"; } } __END__
The way forward always starts with a minimal test.