Skip Menu |
 

This queue is for tickets about the Win32-Process CPAN distribution.

Report information
The Basics
Id: 49619
Status: resolved
Priority: 0/
Queue: Win32-Process

People
Owner: Nobody in particular
Requestors: DJIBEL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.14
Fixed in: 0.16



Subject: Bareword "NORMAL_PRIORITY_CLASS" not allowed while "strict subs"
Download (untitled) / with headers
text/plain 1.7k
Dear, I have to call Win32::Process because my script have to work on Win32 and on Linux machine. Then, I tried to load the module using require but I have some problems. This code work well on Win32 machine #!/usr/bin/perl use warnings; use strict; use Carp; use Win32::Process; my $ProcessObj; Win32::Process::Create( $ProcessObj, 'C:\Program Files\PSPad editor\PSPad.exe', " test.txt", 0, NORMAL_PRIORITY_CLASS, ".") or die Win32::FormatMessage( Win32::GetLastError() ); But this crash #!/usr/bin/perl use warnings; use strict; use Carp; require Win32::Process; my $ProcessObj; Win32::Process::Create( $ProcessObj, 'C:\Program Files\PSPad editor\PSPad.exe', " test.txt", 0, NORMAL_PRIORITY_CLASS, ".") or die Win32::FormatMessage( Win32::GetLastError() ); Message : Bareword "NORMAL_PRIORITY_CLASS" not allowed while "strict subs" If I use no strict 'subs';, the script work but I have a warning : #!/usr/bin/perl use warnings; use strict; use Carp; no strict 'subs'; require Win32::Process; my $ProcessObj; Win32::Process::Create( $ProcessObj, 'C:\Program Files\PSPad editor\PSPad.exe', " test.txt", 0, NORMAL_PRIORITY_CLASS, ".") or die Win32::FormatMessage( Win32::GetLastError() ); Warning: Argument "NORMAL_PRIORITY_CLASS" isn't numeric in subroutine entry at ... Do you have an idea ? Thank you. Best Regards, Djibril
Subject: Re: [rt.cpan.org #49619] Bareword "NORMAL_PRIORITY_CLASS" not allowed while "strict subs"
Date: Fri, 11 Sep 2009 05:27:37 -0700
To: bug-Win32-Process [...] rt.cpan.org
From: Bill Luebkert <dbecoll [...] roadrunner.com>
Download (untitled) / with headers
text/plain 811b
Djibril Ousmanou via RT wrote: Show quoted text
> > I have to call Win32::Process because my script have to work on Win32 > and on Linux machine. Then, I tried to load the module using require but > I have some problems. > > This code work well on Win32 machine
... Show quoted text
> Warning: Argument "NORMAL_PRIORITY_CLASS" isn't numeric in subroutine > entry at ... > > Do you have an idea ?
You need to import the constants you need, but I'm not sure how to get it to handle the import of constants properly. You can workaround the error by declaring your own constants: sub NORMAL_PRIORITY_CLASS { 0x00000020; } sub IDLE_PRIORITY_CLASS { 0x00000040; } sub HIGH_PRIORITY_CLASS { 0x00000080; } sub REALTIME_PRIORITY_CLASS { 0x00000100; } or change them to use constant NORMAL_PRIORITY_CLASS => 0x00000020; ... if you prefer.
Le Ven. Sep. 11 08:28:04 2009, dbecoll@roadrunner.com a écrit : Show quoted text
> Djibril Ousmanou via RT wrote:
> > > > I have to call Win32::Process because my script have to work on Win32 > > and on Linux machine. Then, I tried to load the module using require but > > I have some problems. > > > > This code work well on Win32 machine
> ...
> > Warning: Argument "NORMAL_PRIORITY_CLASS" isn't numeric in subroutine > > entry at ... > > > > Do you have an idea ?
> > You need to import the constants you need, but I'm not sure how to get > it to handle the import of constants properly. You can workaround the > error by declaring your own constants: > > sub NORMAL_PRIORITY_CLASS { 0x00000020; } > sub IDLE_PRIORITY_CLASS { 0x00000040; } > sub HIGH_PRIORITY_CLASS { 0x00000080; } > sub REALTIME_PRIORITY_CLASS { 0x00000100; } > > or change them to > > use constant NORMAL_PRIORITY_CLASS => 0x00000020; > ... > > if you prefer. >
use constant NORMAL_PRIORITY_CLASS => 0x00000020; work well, thank you. Can you explain me what's mean NORMAL_PRIORITY_CLASS ?
Download (untitled) / with headers
text/plain 428b
This has nothing to do with "strict subs". When you "use Win32::Process" then you are importing several symbols at compile time into your own namespace. If you simply "require Win32::Process" at runtime, then those symbols have not been imported and must be used fully qualified: Win32::Process::NORMAL_PRIORITY_CLASS() instead of NORMAL_PRIORITY_CLASS This is not a bug in the module; this is just how Perl works.
Download (untitled) / with headers
text/plain 513b
Le Ven. Sep. 11 13:54:13 2009, JDB a écrit : Show quoted text
> This has nothing to do with "strict subs". When you "use > Win32::Process" then you are importing several symbols at compile time > into your own namespace. If you simply "require Win32::Process" at > runtime, then those symbols have not been imported and must be used > fully qualified: > > Win32::Process::NORMAL_PRIORITY_CLASS() > > instead of > > NORMAL_PRIORITY_CLASS > > This is not a bug in the module; this is just how Perl works.
Thank you
Subject: Re: [rt.cpan.org #49619] Bareword "NORMAL_PRIORITY_CLASS" not allowed while "strict subs"
Date: Fri, 11 Sep 2009 14:24:15 -0700
To: bug-Win32-Process [...] rt.cpan.org
From: Bill Luebkert <dbecoll [...] roadrunner.com>
Download (untitled) / with headers
text/plain 360b
Djibril Ousmanou via RT wrote: Show quoted text
> > use constant NORMAL_PRIORITY_CLASS => 0x00000020; work well, thank you. > > Can you explain me what's mean NORMAL_PRIORITY_CLASS ?
That just means to run the process at the normal base priority of a Win32 process (rather than higher or lower). The names are pretty self explanatory if English is your first language. ;)
Subject: Re: [rt.cpan.org #49619] Bareword "NORMAL_PRIORITY_CLASS" not allowed while "strict subs"
Date: Sat, 12 Sep 2009 14:16:26 -0700
To: bug-Win32-Process [...] rt.cpan.org
From: Bill Luebkert <dbecoll [...] roadrunner.com>
Download (untitled) / with headers
text/plain 739b
Jan Dubois via RT wrote: Show quoted text
> > This has nothing to do with "strict subs". When you "use > Win32::Process" then you are importing several symbols at compile time > into your own namespace. If you simply "require Win32::Process" at > runtime, then those symbols have not been imported and must be used > fully qualified: > > Win32::Process::NORMAL_PRIORITY_CLASS() > > instead of > > NORMAL_PRIORITY_CLASS > > This is not a bug in the module; this is just how Perl works.
Actually the trick is the () on the end. I kept trying to do: require Win32::Process; import Win32::Process qw(NORMAL_PRIORITY_CLASS); my $flags = NORMAL_PRIORITY_CLASS; But all I needed to do was add the (): my $flags = NORMAL_PRIORITY_CLASS();
Download (untitled) / with headers
text/plain 1.2k
Le Sam. Sep. 12 17:16:47 2009, dbecoll@roadrunner.com a écrit : Show quoted text
> Jan Dubois via RT wrote:
> > > > This has nothing to do with "strict subs". When you "use > > Win32::Process" then you are importing several symbols at compile time > > into your own namespace. If you simply "require Win32::Process" at > > runtime, then those symbols have not been imported and must be used > > fully qualified: > > > > Win32::Process::NORMAL_PRIORITY_CLASS() > > > > instead of > > > > NORMAL_PRIORITY_CLASS > > > > This is not a bug in the module; this is just how Perl works.
> > Actually the trick is the () on the end. I kept trying to do: > > require Win32::Process; > import Win32::Process qw(NORMAL_PRIORITY_CLASS); > > my $flags = NORMAL_PRIORITY_CLASS; > > But all I needed to do was add the (): > > my $flags = NORMAL_PRIORITY_CLASS();
It is a good idea. I will use this method. require Win32::Process; import Win32::Process qw(NORMAL_PRIORITY_CLASS); my $flags = NORMAL_PRIORITY_CLASS(); # Create and execute a process to start my $ProcessObj; Win32::Process::Create( $ProcessObj, $executable, $argument, 0, $flags, '.' ) or die Win32::FormatMessage( Win32::GetLastError() ); Thank you.
Download (untitled) / with headers
text/plain 676b
Show quoted text
> You need to import the constants you need, but I'm not sure how to get > it to handle the import of constants properly. You can workaround the > error by declaring your own constants: > > sub NORMAL_PRIORITY_CLASS { 0x00000020; } > sub IDLE_PRIORITY_CLASS { 0x00000040; } > sub HIGH_PRIORITY_CLASS { 0x00000080; } > sub REALTIME_PRIORITY_CLASS { 0x00000100; } > > or change them to > > use constant NORMAL_PRIORITY_CLASS => 0x00000020;
You can simply do: require Win32::Process; Win32::Process->import; That's what 'use' does behind the scenes. I believe this ticket should be closed, to clear up the queue. -- Cheers, ZZ [ https://metacpan.org/author/ZOFFIX ]
Download (untitled) / with headers
text/plain 751b
Le Sam 01 Aoû 2015 17:55:31, ZOFFIX a écrit : Show quoted text
> > You need to import the constants you need, but I'm not sure how to > > get > > it to handle the import of constants properly. You can workaround > > the > > error by declaring your own constants: > > > > sub NORMAL_PRIORITY_CLASS { 0x00000020; } > > sub IDLE_PRIORITY_CLASS { 0x00000040; } > > sub HIGH_PRIORITY_CLASS { 0x00000080; } > > sub REALTIME_PRIORITY_CLASS { 0x00000100; } > > > > or change them to > > > > use constant NORMAL_PRIORITY_CLASS => 0x00000020;
> > You can simply do: require Win32::Process; Win32::Process->import; > That's what 'use' does behind the scenes. > > I believe this ticket should be closed, to clear up the queue.
Dear, Yes, we can close this ticket. Djibel


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.