sub handle_start { my($client,$param) = @_; print $client "Welcome to the game: $param\n"; } # ... more commands ... my %commands = ( start => \&handle_start, # ... more ... ); sub handle { # ... if (not exsits $commands{$commands}) { # bad command } else { # run command $commands{$command}->($client,$param); } # ... }