http://qs1969.pair.com?node_id=11138236


in reply to Re: Iterating over hash to find specific key to sum up the cost
in thread Iterating over hash to find specific key to sum up the cost

your indentation is misleading, the cost entries are at different levels.

You're right that it's misleading, for my reply I assumed there were two closing braces missing right before '135-1' and '1069-9', in which case the cost keys would be at the same level, but your interpretation is possible as well.

vaitor15: Please clarify your input data.

Update: The code in the OP did not compile when I replied because there were missing closing braces. It seems that has now been fixed and you are correct about the nesting.

Replies are listed 'Best First'.
Re^3: Iterating over hash to find specific key to sum up the cost (updated)
by LanX (Sage) on Oct 29, 2021 at 19:56 UTC
    anyway I don't understand the requirement "sums up to 430" either.

    FWIW: This old node shows a recursive walker to dive into a randomly nested structure.

    The OP might want to adapt it to his needs.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      anyway I don't understand the requirement "sums up to 430" either.

      See the last update at the top of my node: the cost keys did originally sum up to 430.

      Update:

      FWIW: This old node shows a recursive walker to dive into a randomly nested structure.

      I've also got some "diver" type code if you search for "dive" on my scratchpad.

        walkers/divers are fun, fuzzy requirements not.

        This OP sounds sufficiently familiar to leave this thread for good!

        See ya! :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery