Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123245]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-28 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found