if (my @matches = grep {$input{$_}} qw(info1 info2 info3)) { print "Matched keys: @matches"; print "Matched values: @input{@matches}"; } else { print "none of the conditions were met\n"; }