use strict; use warnings; use SocketFactory; use IoSelectWrapper; use InputHandler; # all of these could use better names... ;) use More::Stuff; # ... my @hosts = More::Stuff::get_hostnames(); my $sock_fac = SocketFactory->new; $sock_fac->connect( @hosts ); my $io = IoSelectWrapper->new( $sock_fac->sockets ) main_loop($reader); sub main_loop { my $io = shift; my $handler = InputHandler->new; while ( defined(my $input = $io->get_next) ) { $handler->add( $input ); if ($io->is_complete) { $io->reply( $handler->handle ); } } }