Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

when I get a nested array( but its structure is dynamic) How search a value in it and return all the ordinates of the value? I've found searching nested structures is perfect meet what I need, but before I copy&paste, could any monks tell me if there is a module on CPAN can solve this?

  • Comment on how search a value in a nested array/hash?(CPAN way)

Replies are listed 'Best First'.
Re: how search a value in a nested array/hash?(CPAN way)
by Corion (Patriarch) on Jan 03, 2023 at 08:11 UTC

    I think using a CPAN module is likely overkill, but I don't know what kind of values you actually want resp. how deep your structure actually is.

    In the past I've used Data::Diver and Data::DPath for such things (and/or XPath modules), but if your structure is relatively fixed, something from List::Util / List::MoreUtils might work out too.