in reply to Re^4: Help choosing the most efficient, dependable condition(al)
in thread Help choosing the most efficient, dependable condition(al)
"My rationale (which might be an oxymoron) was that if I didn't have an Accept value (one wasn't provided). the unless would ensure an "always valid" -- see; defined value. No?"
No! And that's very easy to test:
#!/usr/bin/env perl -l use strict; use warnings; my %test_hash; if ($test_hash{unset_key} =~ /x/) { print 'true'; } else { print 'false'; } unless ($test_hash{unset_key} =~ /x/) { print 'false'; } else { print 'true'; }
Output:
Use of uninitialized value $test_hash{"unset_key"} in pattern match (m +//) at ./pm_example.pl line 8. false Use of uninitialized value $test_hash{"unset_key"} in pattern match (m +//) at ./pm_example.pl line 15. false
Perhaps you want exists and/or defined.
-- Ken
|
|---|