title: Perl: Iterating through INI files
body: <p>I'm making a Perl script that needs to read and obtain the values of an INI file.</p>
  
  <p>INI File Format:</p>
  
  <pre><code>[name]
  Property=value
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>[switch_6500]
  cpu=1.5.1.12.4
  free_memory=1.45.32.16
  
  [oracle_db_11g]
  param1=value1
  param2=value2
  param3=value3
  param4=value4
  ...
  </code></pre>
  
  <p>As you can see, there can be any amount of sections, that contain any number of parameters. The names of the section names/parameters will always be different.</p>
  
  <p>What I need to do is have my Perl script iterate through every section, and obtain all parameter names/values of that section. What I'm used to doing with INI files is simply specifying the section name along with the name of the parameter like this:</p>
  
  <pre><code>  #!/usr/bin/perl -w
  
    use strict;
    use warnings;
    use Config::Tiny;
  
    # Read the configuration file
    my $Config = Config::Tiny-&gt;new();
    $Config = Config::Tiny-&gt;read( 'configfile.ini' );
    my $Metric1_var = $Config-&gt;{switch_6500}-&gt;{cpu};
    my $Metric2_var = $Config-&gt;{switch_6500}-&gt;{free_memory};
  </code></pre>
  
  <p>However, now that I have an indefinite amount of section names/parameters, as well as not knowing their names, I can't seem to figure out a way to extract all the values. I was looking around at the Config::IniFiles module, and it has some interesting stuff, but I can't seem to find a way to obtain a parameter value without knowing the section/parameter name.</p>
  
  <p>If anyone can help me with iterating through this INI file, it would be greatly appreciated. </p>
  
  <p>Thank you.</p>