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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:13:45+00:00 2026-05-23T12:13:45+00:00

I have a problem accessing variables in a hash of hashes I don’t know

  • 0

I have a problem accessing variables in a hash of hashes I don’t know what I have done wrong. While debugging the value of hash %list1 gives an undef, So I can’t get my values out .

use strict ;
use warnings ;
my $text = "The, big, fat, little, bastards";
my $Author = "Alex , Shuman ,Directory";
my %hashes  = {1,2,3,40};
my %count  = ();
my @lst = split(",",$text);
my $i = 0 ;
my @Authors  =  split(",", $Author);
foreach  my $SingleAuthor(@Authors)
{
    foreach my $dig (@lst)
    {

     $count{$SingleAuthor}{$dig}++;
    }
}

counter(\%count);

sub counter
{
    my $ref  =  shift;
    my @SingleAuthors = keys %$ref;
    my %list1;
    foreach  my $SingleAuthor1(@SingleAuthors)
  {   
   %list1 =  $ref->{$SingleAuthor1};
    foreach my $dig1 (keys %list1)
    {

     print  $ref->{$SingleAuthor1}->{$dig1};
    }
}


}
  • 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-23T12:13:45+00:00Added an answer on May 23, 2026 at 12:13 pm

    In two places you are attempting to assign a hash reference to a hash, which results in this warning: Reference found where even-sized list expected.

    Here are two edits you need:

    # I changed {} to ().
    # However, you never use %hashes, so I'm not sure why it's here at all.
    my %hashes  = (1,2,3,40);
    
    # I added %{} around the right-hand side.
    %list1 =  %{$ref->{$SingleAuthor1}};
    

    See perlreftut for a useful and brief discussion of complex data structures.

    For what it’s worth, your counter() method could be simplified without loss of readability by dropping the intermediate variables.

    sub counter {
        my $tallies = shift;
        foreach my $author (keys %$tallies) {   
            foreach my $dig (keys %{$tallies->{$author}}) {
                print $tallies->{$author}{$dig}, "\n";
            }
        }
    }
    

    Or, as ysth points out, like this if you don’t need the keys:

        foreach my $author_digs (values %$tallies) {   
            print $dig, "\n" for values %$author_digs;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i often run into a problem when variables/attributes have the wrong type. The Problem
I have a problem accessing JSON data. I'm new to JSON and jquery so
I am building my first ASP.Net MVC based app and have a problem accessing
i have problem with libhid . i found that there 2 way 4 accessing
I am having a problem accessing the ViewData object through javascript. I have set
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I'm quite new to JS and jQuery. I have a problem accessing the properties
I have an issue with accessing variables initialized in a switch-statement, and then using
I have a problem with accessing values in the session through pagemethods. The example
EDIT: Problem solved by using $i+1 in function call. I have trouble using variables

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.