in reply to Hash slices ?
Adding a couple more tests to your script gives us a clue:
I would suggest a possible solution would be to abuse grep, thus:
Gives the result:@keys = qw(one two five); unshift @keys,'four'; print "@keys\n"; if (@hash{@keys}) { print "yep\n"; } else { print "nope\n"; } @keys = qw(one two five); push @keys, 'two'; print "@keys\n"; if (@hash{@keys}) { print "yep\n"; } else { print "nope\n"; }
It would appear that only the presence of the last key in the array is affecting whether the test returns true or false.four one two five yep one two five two nope
I would suggest a possible solution would be to abuse grep, thus:
if ( grep{ exists( $hash{$_} ) } @keys ) { print "yep\n"; } else { print "nope\n"; }
In Section
Seekers of Perl Wisdom