in reply to Use of uninitialized variables?
Best practice is to always use strictures, declare variables to minimize their scope and initialize scalars with a useful value at declaration time (except where conditional initialization is required).
Never initialize a scalar variable with a 'junk' value just to shut up warnings! The warnings give you a heads up about bugs in your code.
undef is a vitally important variable state that allows a lot of sanity checking that otherwise is difficult to achieve. Strictures are your friend, perhaps even a best friend.
Note that arrays and hashes don't need to be "initialized". They start empty in any case so something of the form my @array = (); is redundant.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use of uninitialized variables?
by Zadeh (Beadle) on Jun 11, 2008 at 22:40 UTC | |
by GrandFather (Saint) on Jun 11, 2008 at 23:10 UTC | |
by chromatic (Archbishop) on Jun 12, 2008 at 06:39 UTC |