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 6999519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:33:06+00:00 2026-05-27T20:33:06+00:00

I have a two level hash %chainro , each key of $chainro{$ro}{$id} points to

  • 0

I have a two level hash %chainro , each key of $chainro{$ro}{$id}points to an array. The following code is to iterate through the first level of hash, $chainro->{$ro}. I can guess what
does my $file = ${$chainro->{$ro}->$id}}[$i]; aim to perform. However, I do not know why ${$chainro->{$ro}->{$id}}was written this way? In specific, why do we need to add ${ } to wrap the $chainro->${ro}->{$id}

foreach my $id (keys %{$chainro->{$ro}})
{
   $size = $#{$chainro->{$ro}->{$id}};
   for ($i=0; $i<$size; $i++)
   {
     my $file = ${$chainro->{$ro}->{$id}}[$i];
    }
}
  • 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-27T20:33:07+00:00Added an answer on May 27, 2026 at 8:33 pm
    ${ EXPR1 }[ EXPR2 ]
    

    is an alternate way of writing

    EXPR1->[ EXPR2 ]
    

    so

    ${ $chainro->{$ro}->{$id} }[$i]
    

    can be written as

    $chainro->{$ro}->{$id}->[$i]
    

    or even as

    $chainro->{$ro}{$id}[$i]
    

    Cleaned up:

    for my $id (keys %{ $chainro->{$ro} }) {
       my $files = $chainro->{$ro}{$id};
       for my $i (0..$#$files) {
          my $file = $files->[$i];
          ...
       }
    }
    

    Or if you don’t need $i:

    for my $id (keys %{ $chainro->{$ro} }) {
       my $files = $chainro->{$ro}{$id};
       for my $file (@$files) {
          ...
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two array : $data1 = array( (0) => array(level => 1, id
I have a two-level ul/li menu where the li can fire of different onclick-events.
I have two QTreeWidgetItem that are top level. I want to make the second
I have two processes - a user process and a root-level LaunchDaemon. I'd like
I have an ascx component, that holds two-level menu, because there are several user
Here's my problem at a high level: We have two business applications. App1 inputs
I have a menu with two levels, the second level shown in the secondary
I have two applications written in Java that communicate with each other using XML
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have a List which has a two level hierarchy of folders. Something like

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.