Re: Can I 'yield' to the system?
Barry Brevik wrote: > Re: Active Perl 5.8.8 running on Windows. > > Back when I was doing some Assembly language programming, there was a > system call to "yield" to the Windows operating system, in other words, > give up the rest of your time slice. > > Is there a way to do this with Perl? I'm writing an app that > continuously loops waiting for something to do, and it would be good to > give control back to the OS when idle. There is Win32::GUI::DoEvents(), > but I am unsure if this really does the same thing. > how about sleep ... or usleep (provided by Time::HiRes) ? -Mike ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Can I 'yield' to the system?
Re: Active Perl 5.8.8 running on Windows. Back when I was doing some Assembly language programming, there was a system call to "yield" to the Windows operating system, in other words, give up the rest of your time slice. Is there a way to do this with Perl? I'm writing an app that continuously loops waiting for something to do, and it would be good to give control back to the OS when idle. There is Win32::GUI::DoEvents(), but I am unsure if this really does the same thing. Barry Brevik ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Embedding Win32 App in TK
Is it possible to embed a Windows application (GUI or console) in a Perl/TK window? Something like opening a cmd console in a TK script that will accept input and display output. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
> When troubleshooting OLE issues, it is best to have the following code > after each OLE command... > > If (Win32::OLE-> LastError() != 0) { > print "error calling blah: " . Win32::OLE-> LastError() . "\n"; > exit 0; > } > > ...Or something similar, so you can see what OLE had issues with (if > anything). It might lead you in a direction that fixes it. > > Steven Added to the script, but no issues reported. /Michael ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE->LastError() != 0) { print "error calling blah: " . Win32::OLE->LastError() . "\n"; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven > -Original Message- > From: perl-win32-users-boun...@listserv.activestate.com > [mailto:perl-win32-users-boun...@listserv.activestate.com] On > Behalf Of Michael > Sent: Thursday, December 03, 2009 6:19 AM > To: perl-win32-users@listserv.ActiveState.com > Subject: RE: WIN32::OLE WMI Out params > > > Michael <> wrote: > >> Hi, > >> > >> I'm a novice regarding Perl, and need some help converting a > >> VBScript to a PerlScript. > >> > >> The following VBScript returns some data from HP OpenView. The > >> GetChildNodeGroups method returns the number of ChildGroups, > >> > >> and the [out] parameter NodeGroups returns an array which > contains a > >> list of OV_NodeGroup. > >> > >> > From the documentation: > >> > >> sint32 GetChildNodeGroups( > >>[out] OV_NodeGroup NodeGroups[], > >>[in, optional] boolean IncludeSubGroups) > >> > >> Description > >> Returns a list of node groups (instances of OV_NodeGroup) > that are > >> children of this node group. > >> > >> Return Value > >> Number of node groups (children) in the out parameter NodeGroups. > >> > >> ' VBScript Begin > >> > >> Option Explicit > >> > >> Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, > >> arrNodes, objItem > >> > >> Set objWMIService = > >> GetObject("winmgmts:root\HewlettPackard\OpenView\data") > >> > >> Set objOV_NodeGroup = objWMIService.Get("OV_NodeGroup") Set > >> objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = > >> objGetRoot.GetChildNodeGroups(arrNodes, True) > >> > >> WScript.Echo "Child Group Count: " & objChildGroups & vbCrLF > >> > >> For Each objItem In arrNodes > >>WScript.Echo "Name: " & objItem.Name Next > >> > >> ' VBScript End > >> > >> The problem is that I can't find out how to get the array > >> (@arrNodes) in Perl. > >> > >> # PerlScript Begin > >> use strict; > >> use warnings; > >> use Win32::OLE qw(in with); > >> use Data::Dumper; > >> > >> my $objWMIService = > >> > Win32::OLE->GetObject("winmgmts:root/HewlettPackard/OpenView/data") > >> or die "WMI connection failed.\n"; my $objOV_NodeGroup = > >> $objWMIService->Get("OV_NodeGroup"); my $objGetRoot = > >> $objOV_NodeGroup->GetRoot(); > >> > >> my @arrNodes; > >> > >> my $objChildGroups = $objGetRoot->GetChildNodeGroups("@arrNodes", > >> "True"); > > > > And you were doing so well up to this point. I really don't > think that > > you want to pass an empty array, interpolated into a string, as an > > output parameter. In fact, I would expect that it might > even produce a > > run-time error. Does it? > > Nope it does not. The problem is still that @arrNodes is > empty. The GetChildNodeGroups method does not populate the > variable/array like it does in VBScript. Therefore I've been > around "@arrNodes", \...@arrnodes, $nodes etc... > > > > > I don't know the answer, but from my limited Perl/OLE > experience, my > > first guess would be that the function would want to return an OLE > > container object in the output parameter, and so would > expect it to be > > a reference to a scalar. For example: > > > > my $nodes; > > use constant TRUE => 1; > > my $objChildGroups = $objGetRoot-> > GetChildNodeGroups(\$nodes, TRUE); > > > >> > >> print "Child Group Count: " . $objChildGroups . "\n"; > >> > >> print @arrNodes . "\n"; > > > > If I am right, and I may well not be, this would probably > need to be > > something like: > > > > for my $obj (in $nodes) { > > print "Name: $obj-> {Name}\n"; > > } > > > > Yep - but because $nodes/@arrNodes is empty this does not change much. > > >> > >> # PerlScript End > >> > >> Any help would be appreciated. > > > > HTH, in lieu of somebody coming up with a more certain answer. > ___ > Perl-Win32-Users mailing list > Perl-Win32-Users@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
> Michael <> wrote: >> Hi, >> >> I'm a novice regarding Perl, and need some help converting a VBScript >> to a PerlScript. >> >> The following VBScript returns some data from HP OpenView. The >> GetChildNodeGroups method returns the number of ChildGroups, >> >> and the [out] parameter NodeGroups returns an array which contains a >> list of OV_NodeGroup. >> >> > From the documentation: >> >> sint32 GetChildNodeGroups( >> [out] OV_NodeGroup NodeGroups[], >> [in, optional] boolean IncludeSubGroups) >> >> Description >> Returns a list of node groups (instances of OV_NodeGroup) that are >> children of this node group. >> >> Return Value >> Number of node groups (children) in the out parameter NodeGroups. >> >> ' VBScript Begin >> >> Option Explicit >> >> Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, >> arrNodes, objItem >> >> Set objWMIService = >> GetObject("winmgmts:root\HewlettPackard\OpenView\data") >> >> Set objOV_NodeGroup = objWMIService.Get("OV_NodeGroup") Set >> objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = >> objGetRoot.GetChildNodeGroups(arrNodes, True) >> >> WScript.Echo "Child Group Count: " & objChildGroups & vbCrLF >> >> For Each objItem In arrNodes >>WScript.Echo "Name: " & objItem.Name >> Next >> >> ' VBScript End >> >> The problem is that I can't find out how to get the array (@arrNodes) >> in Perl. >> >> # PerlScript Begin >> use strict; >> use warnings; >> use Win32::OLE qw(in with); >> use Data::Dumper; >> >> my $objWMIService = >> Win32::OLE->GetObject("winmgmts:root/HewlettPackard/OpenView/data") >> or die "WMI connection failed.\n"; my $objOV_NodeGroup = >> $objWMIService->Get("OV_NodeGroup"); my $objGetRoot = >> $objOV_NodeGroup->GetRoot(); >> >> my @arrNodes; >> >> my $objChildGroups = $objGetRoot->GetChildNodeGroups("@arrNodes", >> "True"); > > And you were doing so well up to this point. I really don't think that > you want to pass an empty array, interpolated into a string, as an > output parameter. In fact, I would expect that it might even produce a > run-time error. Does it? Nope it does not. The problem is still that @arrNodes is empty. The GetChildNodeGroups method does not populate the variable/array like it does in VBScript. Therefore I've been around "@arrNodes", \...@arrnodes, $nodes etc... > > I don't know the answer, but from my limited Perl/OLE experience, my > first guess would be that the function would want to return an OLE > container object in the output parameter, and so would expect it to be a > reference to a scalar. For example: > > my $nodes; > use constant TRUE => 1; > my $objChildGroups = $objGetRoot-> GetChildNodeGroups(\$nodes, TRUE); > >> >> print "Child Group Count: " . $objChildGroups . "\n"; >> >> print @arrNodes . "\n"; > > If I am right, and I may well not be, this would probably need to be > something like: > > for my $obj (in $nodes) { > print "Name: $obj-> {Name}\n"; > } > Yep - but because $nodes/@arrNodes is empty this does not change much. >> >> # PerlScript End >> >> Any help would be appreciated. > > HTH, in lieu of somebody coming up with a more certain answer. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
Michael <> wrote: > Hi, > > I'm a novice regarding Perl, and need some help converting a VBScript > to a PerlScript. > > The following VBScript returns some data from HP OpenView. The > GetChildNodeGroups method returns the number of ChildGroups, > > and the [out] parameter NodeGroups returns an array which contains a > list of OV_NodeGroup. > >> From the documentation: > > sint32 GetChildNodeGroups( > [out] OV_NodeGroup NodeGroups[], > [in, optional] boolean IncludeSubGroups) > > Description > Returns a list of node groups (instances of OV_NodeGroup) that are > children of this node group. > > Return Value > Number of node groups (children) in the out parameter NodeGroups. > > ' VBScript Begin > > Option Explicit > > Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, > arrNodes, objItem > > Set objWMIService = > GetObject("winmgmts:root\HewlettPackard\OpenView\data") > > Set objOV_NodeGroup = objWMIService.Get("OV_NodeGroup") Set > objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = > objGetRoot.GetChildNodeGroups(arrNodes, True) > > WScript.Echo "Child Group Count: " & objChildGroups & vbCrLF > > For Each objItem In arrNodes > WScript.Echo "Name: " & objItem.Name > Next > > ' VBScript End > > The problem is that I can't find out how to get the array (@arrNodes) > in Perl. > > # PerlScript Begin > use strict; > use warnings; > use Win32::OLE qw(in with); > use Data::Dumper; > > my $objWMIService = > Win32::OLE->GetObject("winmgmts:root/HewlettPackard/OpenView/data") > or die "WMI connection failed.\n"; my $objOV_NodeGroup = > $objWMIService->Get("OV_NodeGroup"); my $objGetRoot = > $objOV_NodeGroup->GetRoot(); > > my @arrNodes; > > my $objChildGroups = $objGetRoot->GetChildNodeGroups("@arrNodes", > "True"); And you were doing so well up to this point. I really don't think that you want to pass an empty array, interpolated into a string, as an output parameter. In fact, I would expect that it might even produce a run-time error. Does it? I don't know the answer, but from my limited Perl/OLE experience, my first guess would be that the function would want to return an OLE container object in the output parameter, and so would expect it to be a reference to a scalar. For example: my $nodes; use constant TRUE => 1; my $objChildGroups = $objGetRoot->GetChildNodeGroups(\$nodes, TRUE); > > print "Child Group Count: " . $objChildGroups . "\n"; > > print @arrNodes . "\n"; If I am right, and I may well not be, this would probably need to be something like: for my $obj (in $nodes) { print "Name: $obj->{Name}\n"; } > > # PerlScript End > > Any help would be appreciated. HTH, in lieu of somebody coming up with a more certain answer. -- Brian Raven This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
WIN32::OLE WMI Out params
Hi, I'm a novice regarding Perl, and need some help converting a VBScript to a PerlScript. The following VBScript returns some data from HP OpenView. The GetChildNodeGroups method returns the number of ChildGroups, and the [out] parameter NodeGroups returns an array which contains a list of OV_NodeGroup. >From the documentation: sint32 GetChildNodeGroups( [out] OV_NodeGroup NodeGroups[], [in, optional] boolean IncludeSubGroups) Description Returns a list of node groups (instances of OV_NodeGroup) that are children of this node group. Return Value Number of node groups (children) in the out parameter NodeGroups. ' VBScript Begin Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject("winmgmts:root\HewlettPackard\OpenView\data") Set objOV_NodeGroup = objWMIService.Get("OV_NodeGroup") Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo "Child Group Count: " & objChildGroups & vbCrLF For Each objItem In arrNodes WScript.Echo "Name: " & objItem.Name Next ' VBScript End The problem is that I can't find out how to get the array (@arrNodes) in Perl. # PerlScript Begin use strict; use warnings; use Win32::OLE qw(in with); use Data::Dumper; my $objWMIService = Win32::OLE->GetObject("winmgmts:root/HewlettPackard/OpenView/data") or die "WMI connection failed.\n"; my $objOV_NodeGroup = $objWMIService->Get("OV_NodeGroup"); my $objGetRoot = $objOV_NodeGroup->GetRoot(); my @arrNodes; my $objChildGroups = $objGetRoot->GetChildNodeGroups("@arrNodes", "True"); print "Child Group Count: " . $objChildGroups . "\n"; print @arrNodes . "\n"; # PerlScript End Any help would be appreciated. /Michael ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs