[sf-perl] a reason to goto

David Alban extasia at extasia.org
Sat Feb 24 13:09:35 PST 2007


What about making a subroutine out of it, to which you pass $REFLEXIVE
(and maybe $i and $j)?  If after calling pick_numeric( ... )
$REFLEXIVE doesn't have the value you want, you recursively call the
subroutine?  I know some folks don't like recursion, and if you
anticipate a large number of recursive calls it could be a performance
issue, but I thought I'd ask.

On 2/24/07, Joe Brenner <doom at kzsu.stanford.edu> wrote:
> I found a reason to use a goto!
>
>   if ($RANDOMIZE) {
>     DO_OVER: do {
>       $i = pick_numeric(0, $numb_cards-1);
>       $j = pick_numeric(0, $numb_cards-1);
>       unless( $REFLEXIVE ) {
>         if ($i == $j) {
>           goto DO_OVER;
>         }
>       }
>     };

-- 
Live in a world of your own, but always welcome visitors.


More information about the SanFrancisco-pm mailing list