Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7839347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:25:17+00:00 2026-06-02T15:25:17+00:00

This is my problem, I’m not very knowledgeable in Perl, and I have this

  • 0

This is my problem, I’m not very knowledgeable in Perl, and I have this function that needs to be fixed.

When this function deviceModelMenu() is called, the CLI displays the following text:

The following models are available
==================================================
1.   
2. Cisco1240 
3. Catalyst3750 
4. Catalyst3650 
5. HP2524 

The first item is empty, which is wrong, and I need to fix that, the piece of code that displays this menu is:

my $features = shift;
print "=" x 50, "\n";
print "The following models are available\n";
print "=" x 50, "\n";
my $i=1;
foreach (keys %{$features->{features}[0]->{deviceModel}})
{
    print "$i. $_ \n";
    $i++;
}

If I add the following line:

warn Dumper($features->{features}[0]->{deviceModel});

It dumps this:

$VAR1 = {
      'deviceModel' => {
                         '' => {
                                 'cfg' => []
                               },
                         'Cisco1240' => {
                                        'cfg' => [
                                                 'cisco1240feature.cfg'
                                               ]
                                      },
                         'Catalyst3750' => {
                                           'cfg' => [
                                                    'catalyst3750feature.cfg'
                                                  ]
                                         },
                         'Catalyst3650' => {
                                           'cfg' => [
                                                    'catalyst3650feature.cfg'
                                                  ]
                                         },
                         'HP2524' => {
                                     'cfg' => [
                                              'hp2524feature.cfg'
                                            ]
                                   }
                       }
    };

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:

if ($_ eq '') {
        shift;
}

But it doesn’t seem to work do what I want. I want to skip the item if it’s empty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:25:20+00:00Added an answer on June 2, 2026 at 3:25 pm

    Well, shifting @ARGV (implicit argument to shift in main program) nor shifting @_ (implicit argument of shift in a function) are not going to help you, because you are not printing either of them.

    You can either:

    1. Not add the '' entry in the first place (depends on how it’s generated)

    2. Remove the '' entry before printing:

      delete $features->{features}[0]->{deviceModel}->{''};
      
    3. Don’t print the entry:

      if($_ eq '') {
          next;
      }
      

      or

      if($_ ne '') {
          print "$i. $_ \n";
          $i++;
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

THIS PROBLEM IS NOW FIXED see updated css below. I currently have: $(form#FanDetail).serialize(), function(){
This problem is very strange, maybe I have missed some small detail, since I'm
This problem has been bothering me for sometime now, I have not settled on
This problem has been kicking my butt for a few days now. I have
This problem involved me not knowing enough of C++. I am trying to access
This problem has bugged me so many times and i have now decided to
This problem is very strange and I'm hoping someone can help me. For the
This problem has been driving me mad. Here's the general gist: I have two
This problem is making me crazy. Actually I have multiple problems. First one: Why
This problem is giving me a real headache. I have two tables in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.