http://www.perlmonks.org?node_id=990827


in reply to Removal of values in array from array list

jemswira,
Is there anything faster than checking like this?

Yes. Or rather, maybe. It is hard to tell from your pseudo notation if you have a hash of arrays, a hash of hashes or just a hash with weird key/value pairs. Assuming you have a hash of hashes then yes.

my @tocheck = qw/Apple Corn Pie Fish/; my %checkfrom = ( Meat => { Fish => 1, Apple => 1, Pork => 1, Bacon => 1, }, Fruit => { Apple => 1, Pie => 1, Orange => 1, Beef => 1, }, ); for my $thing (@tocheck) { for my $category (keys %checkfrom) { delete $checkfrom{$category}{$thing}; } }
If your pseudo notation implied something else. Use real code and repost.

Cheers - L~R

Replies are listed 'Best First'.
Re^2: Removal of values in array from array list
by Anonymous Monk on Aug 31, 2012 at 00:26 UTC
    Well it is a hash of arrays. It's just a small part of my program. The hash and array are both examples. It's actually protein numbers and stuff but the example still Holds.
Re^2: Removal of values in array from array list
by jemswira (Novice) on Aug 31, 2012 at 12:37 UTC

    Reposted