while( ) { next unless m[ACK (...)]i; async( \&checkMAC, $1 )->detach; } #### sub checkMAC{ my $mac = shift; ## If this is a known MAC & it has previously authorised successfully if( exists $clients{ $mac } and $clients{ $mac } ) { ## Check with the activity monitor to see if it has fallen inactive my $active = get "http://activityServer/check.pl?mac=$mac"; ## If is has never fallen inactive, it is known, authorised, and active ## and there is nothing to do return if $active; ## Not sure that this is really necessary, ## but it might save a little resource. lock %clients; delete $clients{ $mac }; } ## Otherwise, check http & Auth and modify status (or add) in %clients my $httpRes = get ...; my $authRes = get ...; lock %clients; $clients{ $mac } = $httpRes && $authRes ? 1 : 0; return. }