in reply to Writing a text adventure in Perl

My suggestion would be to take input, chomp it, then split it on spaces, taking the first as the potential action, then any remaining values as the object, if necessary. Then, you just need to have some structure that has the results of that action, or return a message that says that action could not be performed on the object. Just tossing some code together might look something like this (untested):

while (($alive) and ($playing)) { $input = <STDIN>; chomp($input); my @part = split(/\s+/, $input, 2); if (defined($actions{$part[0]})) { &handle_action(\@part, \$playing, \$alive); } else { print "Huh?\n"; } }

The handle_action routine would then have more logic regarding how to handle individual actions.

Hope that helps, at least give you an idea to start from.