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

  • Home
  • SEARCH
  • 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 6371331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:03:04+00:00 2026-05-25T01:03:04+00:00

I am trying to access a hash within a hash and loop through it

  • 0

I am trying to access a hash within a hash and loop through it to get the values. here is an example of the data

$VAR1 = {
      '24.40.53.143' => {
                          'ServStat' => {
                                          '1.18.118.115.95.99.119.98.98.112.109.45.97.112.95.104.116.116.112.115' => 'vs_cgggbpm-ap_https',
                                          '1.17.118.115.95.99.119.98.115.102.97.45.97.112.95.104.116.116.112' => 'vs_cddedsfa-ap_http',
                                          '20.18.118.115.95.99.119.98.116.119.98.45.98.112.95.104.116.116.112.115' => '0',
                                          '19.17.118.115.95.99.119.98.119.115.45.97.112.95.104.116.116.112.115' => '0',
                                          '2.18.118.115.95.99.119.98.116.119.98.45.98.112.95.104.116.116.112.115' => '0',
                                          '24.18.118.115.95.99.119.98.116.119.98.45.97.112.95.104.116.116.112.115' => '0',
                                          '17.17.118.115.95.99.119.98.119.98.45.97.112.95.104.116.116.112.115' => '0',
                                          '29.17.118.115.95.99.119.98.116.119.112.45.98.112.95.104.116.116.112' => '0',  

I would like to loop through ‘ServStat’ and extract each values. How would I reference the hash ‘ServStat’ so that I can do a foreach on the contents? Something like this:

foreach {ServStat} {
my ( $num, $char, $vs ) = (/(\d+)\.(\d+)\.(.+)/ );
if ($num == 1) { 
print {ServStat}->$value
}
}  

Thank you in advance for any advise you can offer!

  • 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-05-25T01:03:05+00:00Added an answer on May 25, 2026 at 1:03 am

    To get the keys, you can use the function keys on the hash.

    my $data = {
          '24.40.53.143' => {
                              'ServStat' => {'1.18.118.115.95.99.119.98.98.112.109.45.97.112.95.104.116.116.112.115' => 'vs_cgggbpm-ap_https'}
          }
    };
    
    
    my $ServStat = $data->{24.40.53.143}{ServStat};
    
    foreach my $key (keys %{$ServStat}) { # you need the {} to dereference as $ServStat is a hash reference
     ...#Now, in $key, you have the key 1.18.118.115.95.99.119.98.98.112.109.45.97.112.95.104.116.116.112.115
    
    }  
    

    If you just want all values, just use the function values on the hash

    my @values = values %{$ServStat};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to delete certain key/value pairs from a hash, but I get
I'm trying to have a (hash-based) Multimap with a (hash-based) Multiset of values for
I'm trying to parse returned json but can't access the data. Trying to access
I'm using Hash::Util 's lock_keys to die whenever trying to access a non-existing key
I'm trying to figure out how to store a hash in my Access Database.
So I'm trying to get an access token from facebook to use with my
Im trying to access a web service from a remote computer. I managed to
Im trying to access the Magento customer session in another part of my website.
Im trying to access a Sql CE 2005 database on a windows mobile device
I am trying to access Outlook 2007 from C#. I have installed the PIA

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.