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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:36:59+00:00 2026-05-27T17:36:59+00:00

Using hashes in a chaining manner confuses me a lot. For instance, I read

  • 0

Using hashes in a chaining manner confuses me a lot. For instance, I read the following Perl codes, how to understand them piece by piece?

$model->{result}->{forcast}->[$index]->{label}  = 1;

$Neg{$examples->{result}->[$index]->{title}} = 1

In addition, why some items has $ , like $index; while others do not have, like label.

$index is wrapped in [ ] while others are wrapped in { }, what are the differences here?

Is $Neg{$examples->{result}->[$index]->{title}} = 1 equivalent to $Neg{$examples->{result}->[$index]->{title}} = 1

  • 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-27T17:36:59+00:00Added an answer on May 27, 2026 at 5:36 pm

    Consider:

    $model->{result}->{forcast}->[$index]->{label}  = 1;
    

    ->[] is used to dereference an array reference.
    ->{} is used to dereference a hash reference.

    Let us scan it from the left:

    • $model is a hash reference (due to it being used in the context: $model->{})
    • result is a hash key (as it does not have a $ sigil prepended)
    • $model->{result} is again a hash reference
    • $model->{result}->{forcast} is an array reference (due to it being used in the context: $model->{result}->{forcast}->[])
    • $index is a variable set by the user that possibly contains the index of an array item
    • $model->{result}->{forcast}->[$index] is a hash reference
    • label is a hash key
    • $model->{result}->{forcast}->[$index]->{label} sets 1 as the value for the hash key

    Hash keys can be barewords, which will be automatically quoted. So, specifying the hash key as result or 'result' are the same.

    perldoc perldsc is the cookbook for data structures. Data::Dumper is very helpful in viewing such data structures.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to understand the following two lines of Perl codes: %{$self->{in1}->{sv1}} = %{$cs->{out}->{grade}}; and
I am using a lot of hashes in my URL for displaying messages and
How do I compare two hashes in Perl without using Data::Compare?
Perl is warning me about using pseudo hashs in my program: Pseudo-hashes are deprecated
I am trying to compare two Ruby Hashes using the following code: #!/usr/bin/env ruby
how do i get a KEY based on a VALUE in Perl using hashes?
I'm using dynamic multilevel hashes from which I read data but also writes data.
I have never, ever, seen a PHP file using hashes ( # ) for
Before using R, I used quite a bit of Perl. In Perl, I would
I am trying to get a handle on using URL hashes in jQuery to

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.