in reply to complex iterator needed

I don't know if this is gonna help much, but we'll see. If you need to be able to stop and resume functions, create your functions as the loops themselves. I've figured it out in my head, but that's the best I can word it. Maybe some pseudo code would help communicate my meaning...

Instead of using a model like the following...

# USING LOOPS (not gonna work right) my(@directives) = qw/ up down left right left down up right down left up right up down up down down up left left right right right right right left up down up up up up down down left down left up up down down left left left left left left left right up up down right left down down left right right right right right right left left left down up down up down up down up down down right right down up up up up up up up left left right up right left right left right left up down up down right left left left left right down up left right up up /; # "go up, go down, go right, left, etc... while (@directives) { go('^') while &where eq 'up'; go('v') while &where eq 'down'; go('<') while &where eq 'left'; go('>') while &where eq 'right'; } sub where { shift @directives } sub go { print @_ }

...Use a model like this...

# USING SUBS TO EMULATE LOOP ITERATIONS my(@directives) = qw/ up down left right left down up right down left up right up down up down down up left left right right right right right left up down up up up up down down left down left up up down down left left left left left left left right up up down right left down down left right right right right right right left left left down up down up down up down up down down right right down up up up up up up up left left right up right left right left right left up down up down right left left left left right down up left right up up /; my($directions) = { 'up' => sub { '^' }, 'down' => sub { 'v' }, 'left' => sub { '<' }, 'right' => sub { '>' } }; sub go { while (@_) { print &{ $directions->{ shift @_ } } } } go(@directives); # "go up, go down, go right, left, etc...
--
Tommy Butler, a.k.a. TOMMY