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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:02:42+00:00 2026-06-07T17:02:42+00:00

I wish to assign a hash (returned by a method) into another hash, for

  • 0

I wish to assign a hash (returned by a method) into another hash, for a given key.

For e.g., a method returns a hash of this form:

hash1->{'a'} = 'a1';
hash1->{'b'} = 'b1';

Now, I wish to assign these hash values into another hash inside the calling method, to get something like:

hash2->{'1'}->{'a'} = 'a1';
hash2->{'1'}->{'b'} = 'b1';

Being new to perl, I’m not sure the best way to do this. But sounds trivial…

  • 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-07T17:02:43+00:00Added an answer on June 7, 2026 at 5:02 pm

    Your sub might be:

    #!/usr/bin/env perl
    use strict;
    use warnings;
    
    sub mystery
    {
        my($hashref) = { a => 'a1', b => 'b1' };
        return $hashref;
    }
    
    my $hashref1 = mystery;
    print "$hashref1->{a} and $hashref1->{b}\n";
    my $hashref2 = { 1 => $hashref1 };
    print "$hashref2->{1}->{a} and $hashref2->{1}->{b}\n";
    

    One key point is that your notation for accessing the variables with the -> arrow operator is dealing with hash refs, not with plain hashes.

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

Sidebar

Related Questions

In a config file, I have a key to which I wish to assign
I wish to do this using only XAML - How to add an additional
I wish HTML could do something semantically equivalent to this; <dl class=main-list> <definitionitem> <dt>Some
I wish I could figure this out. I need to produce a table with
Somebody must have come up with a solution for this by now. We are
I have written python code which involves the use of dictionaries. I now wish
UPDATE: I've solved this now - see my own comment. Amazing how often writing
I wish to assign to a variable (a constant), a value that will allow
If you have custom type, and you wish to assign a List(of T) to
I have an active form model which has fields I do not wish 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.