Problems? Is your data what you think it is? | |
PerlMonks |
Re: Subroutine Behaviourby TheEnigma (Pilgrim) |
on Sep 25, 2004 at 03:14 UTC ( [id://393740]=note: print w/replies, xml ) | Need Help?? |
@_ is an array, and trying to see if it's equal to something tests the size of the array, not the contents. You should put something like
$num = shift; at the beginning of the subroutine, and then say things like if ($num == 0){ That way you're testing the actual contents of the array. (Also note that the $num inside the subroutine is not the same variable as the $num outside the subroutine; although in this case they will always have the same value.) TheEnigma
In Section
Seekers of Perl Wisdom
|
|