package MyServer; use warnings; use strict; use HTTP::Server::Simple::CGI; use base qw(HTTP::Server::Simple::CGI); our @command_queue; sub handle_request { my ($self, $cgi) = @_; my $cmd_out; # Some processing here which populates $cmd_out push(@command_queue, $cmd_out); myDebug("Command queue has $#command_queue elements"); } my $pid = MyServer->new($PORT)->background(); my $quit=0; while($quit==0) { print "Commands in the queue = $#command_queue\n"; sleep(1); }