in reply to Dealing with Use of uninitialised Values warning
You've gotten good advice on the uninitialized value warnings.
I'd just like to note an alternative way to write this. Your max function can be written in terms of the trinary operator,
I've used map as an alternative to the separate ||= statements. This function is neither worse nor better than yours, other than being smaller and maybe faster. Trinary has advantages when writing lvalue subs, since trinary op produces an lvalue.sub meth3 { my ($first, $second) = map {$_ || 0} @_; $first > $second ? $first : $second; }
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dealing with Use of uninitialised Values warning
by kiat (Vicar) on Nov 21, 2004 at 02:03 UTC |