title: In Perl, how can I skip an empty key when traversing a hash?
body: <p>This is my problem, I'm not very knowledgeable in Perl, and I have this function that needs to be fixed.</p>
  
  <p>When this function <code>deviceModelMenu()</code> is called, the CLI displays the following text:</p>
  
  <pre>The following models are available
  ==================================================
  1.   
  2. Cisco1240 
  3. Catalyst3750 
  4. Catalyst3650 
  5. HP2524 </pre>
  
  <p>The first item is empty, which is wrong, and I need to fix that, the piece of code that displays this menu is:</p>
  
  <pre><code>my $features = shift;
  print "=" x 50, "\n";
  print "The following models are available\n";
  print "=" x 50, "\n";
  my $i=1;
  foreach (keys %{$features-&gt;{features}[0]-&gt;{deviceModel}})
  {
      print "$i. $_ \n";
      $i++;
  }
  </code></pre>
  
  <p>If I add the following line:</p>
  
  <pre><code>warn Dumper($features-&gt;{features}[0]-&gt;{deviceModel});
  </code></pre>
  
  <p>It dumps this:</p>
  
  <pre>$VAR1 = {
        'deviceModel' => {
                           '' => {
                                   'cfg' => []
                                 },
                           'Cisco1240' => {
                                          'cfg' => [
                                                   'cisco1240feature.cfg'
                                                 ]
                                        },
                           'Catalyst3750' => {
                                             'cfg' => [
                                                      'catalyst3750feature.cfg'
                                                    ]
                                           },
                           'Catalyst3650' => {
                                             'cfg' => [
                                                      'catalyst3650feature.cfg'
                                                    ]
                                           },
                           'HP2524' => {
                                       'cfg' => [
                                                'hp2524feature.cfg'
                                              ]
                                     }
                         }
      };</pre>
  
  <p>As you may notice, the first item is indeed empty. I added the following line to skip it, and just print the rest of the info:</p>
  
  <pre><code>if ($_ eq '') {
          shift;
  }
  </code></pre>
  
  <p>But it doesn't seem to <del>work</del> do what I want. I want to skip the item if it's empty.</p>