in reply to Basic optimization questions
The first option is the correct one.
Assigning an empty string or zero is useful if you know you want to print the variable out, and you're not sure it will be assigned to. On the other hand if the assignment might assign undef, then you have to avoid warnings about undef at the print site, rather than at the declaration:
print "Possibly undef var is " . $var || 'undef' . ".\n";
Assigning undef is a waste of typing.
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Basic optimization questions
by ikegami (Patriarch) on Sep 24, 2010 at 21:41 UTC | |
|
Re^2: Basic optimization questions
by JavaFan (Canon) on Sep 24, 2010 at 21:49 UTC |