use strict; use warnings; use DBI; my $dbh = DBI->connect('dbi:WMI:'); my $sth = $dbh->prepare(<<'WQL'); SELECT * FROM Win32_NetworkConnection WHERE ConnectionState != 'Connected' WQL $sth->execute() or die $dbh->errstr; while (my ($con) = $sth->fetchrow_array) { printf "%s\t%s\n", $con->ConnectionState, $con->Name; }