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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:15:30+00:00 2026-06-09T06:15:30+00:00

Forgive a novice question as I am learning Perl. I have some code like

  • 0

Forgive a novice question as I am learning Perl. I have some code like such:

my $familyInfo = [{
            'dad' => 'donald',
            'mom' => 'helen',
            'sister' => 'cate',
}];

Note that this code I cannot modify in any way. What I want to do is extract the mom from this data structure:

my $mother = $familyInfo{mom};
print "mother: $mother\n";

my $mother = $familyInfo[0]{mom};
print "mother: $mother\n";

This doesn’t work at all. It doesn’t assign anything to $mother. What I’m not understanding is exactly what type of structure the initialization creates, and exactly how to use it. Any information you can provide that can help me make sense of this twisted language’s syntax would be helpful!

  • 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-09T06:15:31+00:00Added an answer on June 9, 2026 at 6:15 am

    There are two layers to dereference, the outer layer being an array ref, and the inner layer being a hash ref.

    my $mother = $familyInfo->[0]{mom};
    

    Or to put it another way, $familyInfo holds a reference to an anonymous array. There is only one element. That element contains a reference to an anonymous hash.

    The important component that is different from the sample code you posted is the dereferencing operator, ->.

    Without the arrow operator, you’re telling Perl that $familyInfo[0] is an element of @familyInfo (which it is not, @familyInfo doesn’t even exist). What does exist, is $familyInfo; a scalar containing an array reference, which has to be dereferenced if you want to get at its elements. perldoc perlreftut should help to clarify the syntax.

    If the above doesn’t work for you, then your input data doesn’t match what you’ve shown. In that case, use Data::Dumper to get a closer look at your input data.

    use Data::Dumper;
    print Dumper $familyInfo;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just clarifying something, forgive the novice question. I've got some source code that applies
Forgive me for asking such a novice question, but I can't figure out how
Forgive this novice question (novice in Javascript!). In a html page I have a
Forgive me for the upcoming question, lol. (Im terribly new at this) I have
Forgive me, I'm new to Java and have an extremely basic question. I have
Forgive what might seem to some to be a very simple question, but I
I am a Scala novice so forgive me if this is a stupid question,
Forgive my ignorance if this is 'a basic question'..... I have a method that
Let's say I have the following 2 entities. (Please forgive any code typos, I
Forgive the novice question, i'm new to powershell and am trying to do something

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.