Dean,
I'm no expert on this, but examining my code snippet should
provide the clue (the in construct):
use Win32::OLE qw(in);
# Construct a WMI object instance.
my $WMI = Win32::OLE->GetObject("winmgmts:\\\\mailcd3\\root\\cimv2");
my $WMI = Win32::OLE->GetObject("winmgmts:\\\\mailcd3\\root\\cimv2");
#
Query for the D-drive information.
my $Collection = $WMI->ExecQuery("SELECT * FROM Win32_LogicalDisk where DeviceID = 'D:'");
# Calculate the free-space in megabytes.
my $Space;
for my $Obj (in $Collection) {$Space = int($Obj->{FreeSpace})}
my $Collection = $WMI->ExecQuery("SELECT * FROM Win32_LogicalDisk where DeviceID = 'D:'");
# Calculate the free-space in megabytes.
my $Space;
for my $Obj (in $Collection) {$Space = int($Obj->{FreeSpace})}
Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St.
Louis MO - USA Central Time Zone
636-755-2652 fax
636-755-2503
[EMAIL PROTECTED]
www.nisc.coop
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, August 02, 2005 09:51
To: [email protected]
Subject: YATQ (Yet Another Tyro Question)
Wizards,
I'm doing something wrong here, but the complicated syntax is only confusing me. Here's the code...
45 my $services = $objWMIService->ExecQuery( "Select *
46 From Win32_Service
47 Where ServiceType = '$stype'" );
48
49 for my $j (0 .. [EMAIL PROTECTED]) {
50 push( @ary, @{$services}[$j]->DisplayName );
51 }
$services is the return from the ExecQuery call, and I'm trying to slap the DisplayName properties from it into an array. The syntax error "Not an ARRAY reference" pops up at the for loop line (line #49). As you can no doubt tell from the plethora of gobbledegook surrounding the terminal value, I'm (again) in over my pointy little head. Can someone help me straighten out the slapdash, throw-stuff-at-it-til-it-works, mess I've made of things?
I've got a working version, using the in operator, but this is the only code in a largish module that uses it, so if I can straighten this out, then I don't need to "use" in, and I can decrease the code's footprint.
Thanks!
Deane
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
