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

save yourself some typing, ropey!

print "You have chosen option $input\n" if ($input >= 1 && $input <= 6 +);

~Particle ;Þ

Replies are listed 'Best First'.
Re: Re: Re: simple menu loop problems
by ropey (Hermit) on Mar 12, 2002 at 16:53 UTC
    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 ! :)
      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!'