Phoenix.pm: Please help, my brain is fried

Scott Walters root at nebuchadnezzar.slowass.net
Wed Jan 26 21:07:33 CST 2000


> 
>   sub get_char(){
>       srand;
>       $count++;
> 
>       my $char = int(rand(57))+65;
>       print $count, "  ", chr($char), "\n";
> 
>       get_char() if ($char >= 91 && $char <= 96);
        $char=get_char() while($char >= 91 && $char <=96);        
>       return $char;
>   }
> 

Sorry, I'm one of those people who edits, saves, realizes he wasnt
thinking, edits again, saves, then runs the code...
Yes, $char does go out of scope, and there is a respectable chance each
that you will get two values, both of which are out of range, in a row,
in which case you need a while, not an if.





More information about the Phoenix-pm mailing list