in reply to Re^2: A more elegant way to filter a nested hash?
in thread A more elegant way to filter a nested hash?

I had the same idea, but you are effectively iterating twice over the keys if you slice first.

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

  • Comment on Re^3: A more elegant way to filter a nested hash?

Replies are listed 'Best First'.
Re^4: A more elegant way to filter a nested hash?
by Veltro (Hermit) on May 31, 2018 at 18:57 UTC
    I don't think so. I am iterating over the 'selected' keys twice.

    2018-06-09 Athanasius restored original content

      I count the slice as iteration. It's fast but doesn't come without a price.

      I also think there are differences in error handling, a missing value will be reported as undef when you slice, without raising an error.

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

        What price is higher then using map or grep? I don't see it. The only iteration that is done twice is over the keys of the result-set which is necessary because of autovivification. The fact that missing values become undefined instead of non-existent is actually something that I would prefer in case the filter asked for it.

        2018-06-09 Athanasius restored node content