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

Greetings kcott, and thank you for taking the time to respond.

It's me. I'm sure of it.

Which is why I came here to ask. :)

OTOH I've used this method for at least a couple of years now. With the exception of an occasional "Use of uninitialized value $ENV{"HTTP_ACCEPT"}...". I can't see any issue(s).

But that doesn't mean it's correct.
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^2: Help choosing the most efficient, dependable condition(al)

Replies are listed 'Best First'.
Re^3: Help choosing the most efficient, dependable condition(al)
by kcott (Archbishop) on Nov 13, 2013 at 19:47 UTC

    The point I was making is that what you've "been using", and what you're considering "might be a better choice", use identical logic: the logic is written differently but both achieve the same result.

    I've looked long at the condition and TRUE/FALSE code in both but can't see any difference. It's possible I'm missing something: if not, then your not really changing anything and perhaps there's a typo in your posted code.

    -- Ken

      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;
        "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