my %handlers = ( tell => \&tell_user, msg => \&tell_user, chatoff => \&toggle_chat, chaton => \&toggle_chat, moo => \&order_cheese, ); my( $command, $rest ) = split( /\s+/, $line, 2 ); $command =~ s{^/}{}; # throw away / if( exists( $handlers{ lc($command) } ) { $handlers{ lc($command) }->( $rest ); } else { send_error( "Unknown command `$command'" ); }