in reply to problem with input command
sub help { print(@_); print(" This is help?\n"); } sub list { print("This is list\n"); } our $commands = { 'help' => \&help, 'list' => \&list, }; while (<STDIN>) { chomp; if ((my $name) = ($_ =~ /^(\w+)/)) { if (defined $commands->{$name}) { $commands->{$name}->($_); } else { print "I Don't understand $name\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: problem with input command
by muba (Priest) on Mar 27, 2005 at 12:35 UTC | |
by jhourcle (Prior) on Mar 27, 2005 at 12:44 UTC |