in reply to conditional print. Is correct to use it?

I typically initialize variables explicitly to undef (as in my $var = undef;) if I cannot produce a meaningful initial value at that point in the program. If this is done, then the test to later determine if a value was produced is simply defined($var) and usually producing an undefined value is just as bad as producing no value, so die "..." unless defined($var); works well to bail out on error later.

And just a reminder, you are including use strict; and use warnings;, right?

Replies are listed 'Best First'.
Re^2: conditional print. Is correct to use it?
by pvaldes (Chaplain) on Oct 28, 2020 at 14:21 UTC

    yep. use strict; use warnings; and use criticism 'brutal'; :-) I'm reviewing my old scripts