in reply to Re: Re: simple menu loop problems
in thread simple menu loop problems

I would agree however .... what happens if the code changes to call different functions instead of printing ??? I was presuming the code supplied was an example ! :)

Replies are listed 'Best First'.
(jeffa) 4Re: simple menu loop problems
by jeffa (Bishop) on Mar 12, 2002 at 17:26 UTC
    Then you use a dispatch (or lookup) table:
    my %choice = ( 1 => 'stuff', 2 => 'more stuff', ... ); print $choice{$input}, "\n"; # hey, let's make functions now! my %choice = ( 1 => \&stuff, 2 => \&more_stuff, ... ); &{$choice{$input}};
    See Re: How to write long programms? for more.

    jeffa

    'Welcome to the next level of laziness!'