in reply to Re^3: Help choosing the most efficient, dependable condition(al)
in thread Help choosing the most efficient, dependable condition(al)

Greetings kcott, and thank you for the followup.

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?

I think this speaks volumes on how I think. Kinda' scary. It's so revealing. :)

Thanks again, for taking the time to respond!

--Chris

#!/usr/bin/perl -Tw
use Perl::Always or die;
my $perl_version = (5.12.5);
print $perl_version;
  • Comment on Re^4: Help choosing the most efficient, dependable condition(al)

Replies are listed 'Best First'.
Re^5: Help choosing the most efficient, dependable condition(al)
by kcott (Archbishop) on Nov 13, 2013 at 20:35 UTC
    "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