while () { my ( $cmd, @args ) = split; if ( exists( $command{$cmd} )) { $command{$cmd}->( @args ); else { $command{default}->(); } }