#!/usr/bin/perl use warnings; use strict; $|++; use vars qw( $AUTOLOAD $running ); $running = 1; while ($running) { my $input = <>; my ($action, @args) = split ' ', $input; # probably not robust enough $action = lc( $action ); no strict 'refs'; &$action( @args ); # dispatch based upon action } sub go { my @args = @_; print "You go @args\n"; } sub quit { my @args = @_; $running--; print "Thanks for playing\n"; } sub AUTOLOAD # catches calls to non-existent methods { my @args = @_; my ($method) = $AUTOLOAD =~ m/::(:?\w+)$/; print "I don't understand $method @args\n"; }