Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Nested iterations throgh hash (updated)

by AnomalousMonk (Bishop)
on Feb 11, 2020 at 20:25 UTC ( #11112804=note: print w/replies, xml ) Need Help??

in reply to Nested iterations throgh hash

But what is the best practical solution for this task?

But what is the task? Is it to access the "next" key/value element of the hash in the inner loop? If so, then an array structure would seem more appropriate since a hash has no inherent order beyond key-value pairing (but there are tie-ed, ordered hashes). (Update: As to copying, if you make a copy of the hash by value, you will just end up with two independent each iterators for each copy. If you make a copy of the reference, you're still just operating on the same hash referent!)

What output do you want from your code?

Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Nested iterations throgh hash
by luxs (Beadle) on Feb 11, 2020 at 20:33 UTC

    In this example, I've try to make the problem very simple, without overwhelming practical applications.

    But the main idea is - I need to do some job for each hash pair. And during this job, I do need to calculate some information related to all pairs from this hash for example.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11112804]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2020-05-24 23:34 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (142 votes). Check out past polls.