#!/usr/bin/perl use warnings; use strict; use threads; use threads::shared; my $tgo:shared = 0;; my $tdie:shared = 0; my $thread = threads->new(\&check_it); # setup a timer or use a while loop here # probably need to Control-C out of this loop # unless you add some keyboard checking for a q # or whatever while(1){ sleep 10; $tgo = 1; print "starting check\n"; } $tdie = 1; $thread->join; print "done press any key to exit\n"; <>; ################################################### sub check_it { use SOAP::Lite; $|++; # this will be persistent in the thread my $soap_client = SOAP::Lite->uri('myuri') ->proxy('http://serviceendpoint', timeout => 30, keep_alive => 1); while(1){ if($tdie == 1){ return }; if ( $tgo == 1 ){ print "soap start\n"; $soap_client->call('SomeMethod',$paramter); print "soap done\n"; $tgo = 0; #turn off self before returning to sleep }else { sleep 1 } } } __END__