#! perl -slw use strict; use threads qw[ async ]; use threads::shared; use Win32::OLE qw (in); my @servers = qw[ servera serverb serverc ]; my $namespace="\\root\\cimv2"; for my $server ( @servers ) { my $gotObject : shared = 0; my $gotInfo : shared = 0; my %info : shared; async { my $object=Win32::OLE->GetObject( 'winmgmts:{impersonationLevel=impersonate,(security)}//' . $server . $namespace ) or die "could not get object"; $gotObject = 1; # NOW GET DRIVE INFO THROUGH WMI $info{ somekey } = 'somevalue'; $info{ someotherkey } = 'someothervalue'; ## Yada yada undef $object; ## Last thing before exiting thread. $gotInfo = 1; }->detach; my $timeout = 30; sleep 1 while $timeout-- and not $gotObject; unless( $timeout ) { print "Failed to make connection to $server"; next; } sleep 1 until $gotInfo; print "Received from $server"; print "$_ => $info{ $_ }" for sort keys %info; }