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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:12:47+00:00 2026-06-12T17:12:47+00:00

Given that $struct is a data structure that can be either a hash or

  • 0

Given that $struct is a data structure that can be either a hash or an array reference, I have some code that looks like this:

for (ref($struct) eq "HASH" ? values %$struct : values @$struct) {  
    # process $_
    ...
}

I would like to use the new functionality of the values function (to accept a reference to an unblessed hash or array) to write this instead, which works in my 5.14.2 release:

for (values $struct) {  
    # process $_ 
    ...
}

So much prettier!

But the documentation for values says that this feature is “highly experimental.” It has been around for several releases now (5.12 through 5.16.0 as far as I can tell). Does anyone know what the status is? How is the experiment working out?

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

    It’s marked as experimental because it’s a controversial change. It’s controversial because it doesn’t work on all references to hashes.* No new has been discovered since the feature was introduced, but I don’t think anyone expected any new problems to be discovered.


    * — values($hash) can fail where values(%$hash) would succeed. Your original code has exactly the same problem, so this “limitation” of values isn’t a problem for you.

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

Sidebar

Related Questions

So, given that I have some type of data structure like this within a
I have been given a task of inputting some student data, like option 1:
Say i have a data structure like this: type Foo struct { Bar []struct
Given that the web application doesn't have su privileges, I'd like to execute a
Given that I have this resultset structure (superfluous fields have been stripped) Id |
I have the following data structure in C: typedef struct { void* buffer; ...
My application is written in C. I have a module that uses some data
I have an abstract data type that points to a concrete data type structure.
Given that I have a Foo model w/ the standard Rails timestamp columns what
Given that EVAL is Evil how do I create an Array name dynamically: I

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.