If all you really want it's to *check* the connection status, I'd avoid using such an approach because it's slow and auto-vivifying (Windows tries to activate each connection you want to read from).
IMHO a better way would be to query the Windows Management Instrumentation (WMI) infrastructure through DBD::WMI:
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;
}