use Win32::OLE qw( in ); my $wmi_service = Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2") or die("Unable to connect to WMI: $!\n"); # DriveType 3 = local hard disk my $disk_col = $wmi_service->ExecQuery(" SELECT DeviceID FROM Win32_LogicalDisk WHERE DriveType = 3 "); my @drives = map { $_->DeviceID } in $disk_col; local $, = ", "; local $\ = "\n"; print @drives;