use strict; use threads; use threads::shared; use IO::Socket::INET; my @option = ('Mud Server',''); my @votes: shared = (0,0,0); my $listen = IO::Socket::INET->new(LocalPort=>4546,ReuseAddr=>1, Listen => 10); sub request{ my $req=shift; print $req "Welcome to the vote server. \n Please Choose:"; for (@options) { print $req $i++.": $_ \n"; } sig{ALRM}= ssub{die}; eval{ alarm 60 ; my $option = <$req>; chomp $option; if ($option > 0 && $option < $i ) { $option--; lock(@votes); $votes[$option]++; print $req "Your Vote is Registered"; } else { print $req "Incorrect reqponce"; } close($req) } } while (my $sock = $listen->accept() ) { threads->new(\&request, $sock); }