How can I assign a boolean condition result to a scalar variable in perl?
问题 I am doing the following, but it is not working properly: my $enabled = $hash && $hash->{'key'} && $hash->{'key'}->{'enabled'} && $hash->{'key'}->{'active'}; Is this an acceptable way to assign a boolean value to a scalar variable? My code is misbehaving in strange ways, as it is, and I believe it is because of this assignment. I have validated that the individual values exist for all of these keys and are set to a value. P.S. Sorry for being a noob! I googled for ~10 minutes and couldn't