in reply to Building a Hash of arrays from a hash of arrays based on a list?
my @really_big_array = ({fruit=>apple},{vegitable=>'lettuce'},{fruit=> +'oranges'},{vegitable=>'carrot'}); # put all entries with a 'fruit' key in a new array my @smaller_array = (); foreach(@really_big_array) { push(@smaller_array,$_) if($_->{fruit} ne ""); }
If you didn't want to do it by key you could test the value of the key against something, my example if you wanted all the apples (say you have another key for type). You could do:
push(@smaller_array,$_) if($_->{fruit} eq "apple");Hope that helps, Reply if it doesn't make sense
Chris
|
|---|