Acme-RTB
view release on metacpan or search on metacpan
Copyright 2003 by Anarion
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
STDOUT->autoflush(1);
STDERR->autoflush(1);
my $select = IO::Select->new();
$select->add(*STDIN);
my %actions = ( Initialize => \&initialize,
YourName => \&your_name,
YourColour => \&your_color,
GameOption => \&game_option,
GameStarts => \&game_starts,
Radar => \&radar,
Info => \&info,
RobotInfo => \&robot_info,
RotationReached => \&rotation_reached,
if(exists $actions{$key} and ref($code) eq "CODE")
{
$actions{$key} = $code;
}
}
###
sub process_lines
{
my $self = shift;
while(my @l = $select->can_read(0.1))
{
my $hd = $l[0];
my $msg = <$hd>;
chomp($msg);
print LOG "<--- $msg\n" if $self->{Log};
my ($cmd, @options) = split' ',$msg;
$cmd = 'Unknown' unless exists $actions{ $cmd };
$actions{ $cmd }->($self, @options)
}
}
( run in 0.636 second using v1.01-cache-2.11-cpan-49f99fa48dc )