in reply to (duplicate) Eek! goto?

This is the construct I generally use, although TheDamian's new switch module is probably better overall.

SWITCH: for ($num) { /11/ && do { $c += $k[10] << 24; last SWITCH; }; /10/ && do { $c += $k[9] << 16; last SWITCH; }; # ...and so forth. # Default action. }

"The dead do not recognize context" -- Kai, Lexx

Replies are listed 'Best First'.
Re: Re: Eek! goto?
by BrowserUk (Patriarch) on Feb 12, 2003 at 00:10 UTC

    That doesn't quite work. There are no breasks in the original, it falls through all cases below the starting point. Other than decrementing $num and getting into a !$num tests loops, I can't see how to convert that?


    Examine what is said, not who speaks.

    The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

      Oh, okay. Replace last SWITCH with $num-- and goto SWITCH or merely $num-- and you'll fall through.
      "The dead do not recognize context" -- Kai, Lexx