From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 02 August 2005 15:51
To: [email protected]
Subject: YATQ (Yet Another Tyro Question)
---INTERNET EMAIL NOTIFICATION---
This email originates from the Internet and therefore may not be
from the apparent sender. Please check any attachments carefully before
opening them as they may not be as they appear.
If you have any doubts about the origin or content of the email
please contact PC Support on x2288.
---
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 }
First, if $services is an array ref then that is more complex than
necessary. You don't need an index, e.g.
push @ary, $_->DisplayName foreach @$services;
$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.
Well, given that you get "Not an ARRAY reference", and using "in" works,
my guess would be that $services is not an array ref, but it is an OLE
collection. I don't know what relevance the code's footprint has, but,
as with all optimisation, the first priority is making the program work.
I that means using "in", then use it.
HTH
--
Brian Raven
-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely
for the intended addressee(s). Unauthorised reproduction, disclosure,
modification, and/or distribution of this email may be unlawful. If you
have received this email in error, please notify the sender immediately
and delete it from your system. The views expressed in this message
do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary
companies.
-----------------------------------------------------------------------
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs