Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: conditional print. Is correct to use it?by jcb (Parson) |
on Oct 28, 2020 at 02:12 UTC ( [id://11123245]=note: print w/replies, xml ) | Need Help?? |
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?
In Section
Seekers of Perl Wisdom
|
|