On 4/15/10 Thu  Apr 15, 2010  9:21 AM, "Harry Putnam" <rea...@newsguy.com>
scribbled:

> r...@i.frys.com writes:
> 
>> Here's an example I gave in a similar question in another
>> forum.
> 
> Thanks... 
> 
> I'm sorry to ask more but if someone asked to be shown an
> if/elsif/else construct being replaced by a dispatch table, I don't
> really see how that answered there question.  It didn't for me.
> 
> Where is the comparable if/elsif/else construct that is being replaced
> by the dispatch table?
> 
> Visualizing how it would go is a little beyond my grasp I guess.


Something like this:

  print "press 1 to get CPU Info \n",
        "press 2 to get OS version \n",
        "press 3 to get CPU Load averages\n",
        "press 4 to get System Load & Uptime\n",
        "press 5 to get Net Interface info\n",
        "press 6 to get system disk usage info \n",
        "press 7 to get IP address info \n";
        "press q to Exit\n"

  chomp(my $selection) = <STDIN>;
  if( $selection eq '1' ) {
    getcpuinfo();
  }elsif( $selection eq '2' ) {
    osversion();
  }elsif{ $selection eq '3' ) {
    loadaverages();
  }elseif( $selection eq '4' ) {
    systemload_uptime();
  ]elsif( 
    ...
  }else{
    print "Dispatch error\n";
  );





-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to