[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Does a hash contain any keys other than <LIST>?



Given a hash %h (in my case, %h is tied, but I don't think it'll matter), I 
want to know just whether it contains any keys *other* than those listed 
in, say, @k. My somewhat pedestrian solution:

my %t; 
@t{keys %h} = (); 
delete @t{@k}; 
print "Yes!" if keys %t;

Anything better? (Yeah, you could optimize it by testing first if @k > 
keys %h, but in my case there are very few keys.)

Peter Scott 
Pacific Systems Design Technologies



==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org