in reply to Re^4: How to determine if an array contains an undef value?
in thread How to determine if an array contains an undef value?

If $val is undef the loop ends
$ perl -MO=Deparse -le " while (my $val = shift @array) { print $val } + " BEGIN { $/ = "\n"; $\ = "\n"; } while (my $val = shift @array) { do { print $val }; } -e syntax OK

$error_count++ and next if some_condition();

Comma to the rescue

$error_count++, next if some_condition();

Replies are listed 'Best First'.
Re^6: How to determine if an array contains an undef value?
by Laurent_R (Canon) on Jan 05, 2015 at 23:22 UTC
    If $val is undef the loop ends
    Yes, right (++), although there are many cases where you know this can't happen. But you are absolutely correct, $val may also be "0" or "", and that is more common. This syntax is broken or at best very dangerous. Which is the reason, BTW, why I would rather use the syntax of first example above, which does not have this problem. I've just corrected my post to strike out this example. Thanks for calling my attention on this.

    Comma to the rescue
    Yes, thanks, I know you can do that, I was just trying to give an example of a stupid mistake I did 4 or 5 years ago when trying to be too clever.

      Hello Laurent_R,

      Thank you for your time and effort you examples are enlightening to me.

      Thank you for your time and effort.

      Seeking for Perl wisdom...on the process of learning...not there...yet!