in reply to Re^4: CLI using hashes
in thread CLI using hashes
Along with the fine comments by fishbot_v2, I'd also like to point out that your subroutines need not be named. This is the perfect situation to use anonymous subroutines. Here's how I would define your hash:
my %commands = ( "set time" => sub { print "nMetrics>You have entered the settime command\n"; print "nMetrics>The argument given is $_[0]\n"; }, "show time" => sub { print "nMetrics>You have entered the show time command\n"; }, default => sub { print "nMetrics>Invalid command line options\n"; } );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: CLI using hashes
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 |