in reply to uninitialized variables
Or you couldwhile(<>) { my ($x, $y, $z) = (0,0,0); ($x, $y, $z)=split; # do whatever }
But then you have to be ready to handle 0's (or whatever other default you chose) when data is missing, and you have to make sure you don't pick a default value that could be real data.while(<>) { my @flds=split; my ($x, $y, $z)=(@flds,0,0,0); # do whatever }
It's much safer to use defined and know when your fields are missing; that way you get something like real NULL handling, in the SQL sense.
--
Mike
Edit: thanks to ariels for the correction!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: uninitialized variables
by ariels (Curate) on Mar 28, 2002 at 17:29 UTC |