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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:23:03+00:00 2026-06-11T17:23:03+00:00

Say I have a hash that I can index as: $hash{$document}{$word} From what I

  • 0

Say I have a hash that I can index as:

$hash{$document}{$word}

From what I read online (although I could not find this on perlreftut, perldsc or perllol), I can slice a hash using a list if I use the @ prefix on my hash to indicate that I want the hash to return a list. However, if I try to slice my hash using a list @list:

@%hash{$document}{@list}

I get several "Scalar values ... better written" errors.

How can I slash a nested hash in Perl?

  • 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-11T17:23:05+00:00Added an answer on June 11, 2026 at 5:23 pm

    The sigill for your hash must be @, like so:

    @{$hash{$document}}{@list}
    

    Assuming @list contains valid keys for %hash it will return the corresponding values, or undef if the key does not exist.

    This is based on the general rule of a hash slice:

    %foo = ( a => 1, b => 2, c => 3 );
    print @foo{'a','b'};               # prints 12
    %bar = ( foo => \%foo );           # foo is now a reference in %bar
    print @{ $bar{foo} }{'a','b'};     # prints 12, same data as before
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say that I have only DHT (distributed hash table) implemented (in Python), and
I have four arrays that are coming in from the client. Let's say that
I have a question that seems basic, but I can't figure out. Say that
Say I have a scheme that derives a key from N different inputs. Each
Say I have a hash with a list of delivery drivers (for the classic
Let's say I have a hash in Ruby like this: d = {1 =>
So lets say I have a hash a = { foo : bar ,
I'm trying to do the following say; I have a hash: {word1 => {doc1
Say a user registers for your site, you hash the password they have chosen
I have a unordered_hashmap that maps a string (say personName or SSN) to a

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.