#!/usr/bin/perl -w package main; use strict; use DBI; use Data::Dumper; my $dbh = DBI->connect('dbi:WMI:foo'); my $sth = $dbh->prepare(<execute(); # loops forever while (defined (my $row = $sth->fetchrow_arrayref())) { my $ev = $row->[0]; # Windows XP only :( print join "\t", $ev->{DeviceID}, $ev->{Caption}, $ev->{MediaType}; print $ev->Path_->Class,"\n"; print $ev->TargetInstance->Name, $ev->TargetInstance->Caption,"\n"; }