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"; } } }
In reply to Re: problem with input command
by gam3
in thread problem with input command
by white-fox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |