in reply to Re: uninitialized variables
in thread uninitialized variables
There's a subtle difference between the 2 forms you suggest: only the second works!
When you say
you always set $x, $y and $z! That's what assignment is all about!my ($x, $y, $z) = (0,0,0); ($x, $y, $z)=split;
Here it is in the debugger:
main::(-e:1): 0 DB<1> ($x,$y,$z)=(2,3,4) DB<2> ($x,$y,$z)=split ' ',"two words" DB<3> x $x 0 'two' DB<4> x $y 0 'words' DB<5> x $z 0 undef
The second works, because it isn't trying to reassign undef.
|
|---|