use List::Util 'reduce'; if (reduce { $a && exists $$a{$b} ? $$a{$b} : undef } \%foo, 'bar', 'baz', 'troz') { }