title: perl: Config::Simple config file section reading
body: <p>I am trying to do the configuration file using <code>Config::Simple</code> </p>
  
  <p>The configuration file i.e. new1.conf</p>
  
  <pre><code>[Section1]
  param1=value1
  param2=value2
  
  [Section2]
  param1=value1
  param2=value2
  
  [Section3]
  param1=value1
  param2=value2
  </code></pre>
  
  <p>here is my code</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>use Config::Simple;
  
  $cfg = new Config::Simple(syntax =&gt; 'ini');
  
  #
  # Get Section Names
  # 
  $cfg = Config::Simple-&gt;import_from('new.conf', \%Config)  or die Config::Simple-&gt;error();
  my @arr = ( keys %Config );
  @arr1 = grep s/\..*//, @arr;
  my %uniq;
  @uniq{@arr} = ();
  @sections = keys %uniq;
  
  foreach my $secname (sort @sections) 
  {
      print "section : $secname\n";
      foreach (sort keys %Config) 
      {
  
          print "$_ : $Config{$_}\n";
  
      }
  }
  </code></pre>
  
  <p>For this i am getting the output like this </p>
  
  <pre><code>section : Section1
  Section1.param1 : value1
  Section1.param2 : value2
  Section2.param1 : value1
  Section2.param2 : value2
  Section3.param1 : value1
  Section3.param2 : value2
  section : Section2
  Section1.param1 : value1
  Section1.param2 : value2
  Section2.param1 : value1
  Section2.param2 : value2
  Section3.param1 : value1
  Section3.param2 : value2
  section : Section3
  Section1.param1 : value1
  Section1.param2 : value2
  Section2.param1 : value1
  Section2.param2 : value2
  Section3.param1 : value1
  Section3.param2 : value2
  </code></pre>
  
  <p>I am trying to compare the section names with paramaters in that respective section.</p>
  
  <p>for that i am trying to write this code</p>
  
  <pre><code>foreach my $secname (sort @sections) 
  {
      print "section : $secname\n";
      foreach (sort keys %Config) 
      {
          $var = grep { !/\b[A-Za-z0-9.].*[.]/ } @arr;
          if($secname == $var)
          {
              print "$secname\n";
          }
          else
          {
              print "false\n";
          }
  
          #compare 'secname' vs 'dialer onboard'.xxx
          #print "$_ : $Config{$_}\n";
  
      }
  }
  </code></pre>
  
  <p>This is not working for me. I stuck up here only.For this i am getting output like this </p>
  
  <pre><code>section : Section1
  false
  false
  false
  false
  false
  false
  section : Section2
  false
  false
  false
  false
  false
  false
  section : Section3
  false
  false
  false
  false
  false
  false
  </code></pre>
  
  <p>I cant be able to compare and display the section name with the respective params and values.</p>
  
  <p>And finally i want output like this below.</p>
  
  <pre><code>section : Section1
  Section1.param1 : value1
  Section1.param2 : value2
  section : Section2
  Section2.param1 : value1
  Section2.param2 : value2
  section : Section3
  Section3.param1 : value1
  Section3.param2 : value2
  </code></pre>
  
  <p>or at least i want to display the params.
  I think i am doing something wrong in comparing params and section. I am not able to identify that.</p>
  
  <p>Please somebody suggest me where i am going wrong
  Thanks in advance.</p>