in reply to Re^3: CLI using hashes
in thread CLI using hashes
i cant understand how i am going to pass arguments to my sub routines. can u just specify who i can pass arguments in this sort of a set up?sub settime($){ print "nMetrics>You have entered the settime command\ +n"; print "nMetrics>The argument given is $_[0]\n" +;} sub showtime{ print "nMetrics>You have entered the show time c +ommand\n";} sub error{ print "nMetrics>Invalid command line options\n";} $myhash{"set time"}=\&settime; $myhash{"show time"}=\&showtime; $myhash{default}=\&error; print "Welcome to nMetrics application monitor\n"; print "Please type in a command\n"; label:print "nMetrics>"; while(<STDIN>) { chomp; if (exists $myhash{$_}) {$myhash{$_}->();} else {$myhash{default}->();} goto label; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: CLI using hashes
by fishbot_v2 (Chaplain) on May 30, 2005 at 03:22 UTC | |
|
Re^5: CLI using hashes
by revdiablo (Prior) on May 30, 2005 at 05:37 UTC | |
by bahadur (Sexton) on May 30, 2005 at 05:59 UTC | |
by graff (Chancellor) on May 30, 2005 at 08:32 UTC | |
by polettix (Vicar) on May 30, 2005 at 08:14 UTC |