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

Hi Monks,

I have an array e.g.
my @array = ( {x => 1, y => 2, z => 3}, {x => 4, y => 5, z => 6}, #etc );
I can search through it:
grep {$_->{x} == 4 } @array;
but how do I store the entire hash with matching key?

UPD:Please delete this question. I was too tired to use my brain :-)
my @newarray = grep {$_->{x} == 4 } @array;

Replies are listed 'Best First'.
Re: Search through array of hashrefs and store matching
by ww (Archbishop) on Jan 23, 2015 at 16:52 UTC
      my apologies. content restored.
      Sapienti sat.

        Upvoted (and OPed node) for prompt consideration of Monastery practice!


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

        Upvoted for the same reasons as AnomalousMonk's.

        Je suis Charlie.