in reply to require Win32::Process, barewords "THREAD_PRIORITY_BELOW_NORMAL" not allowed?

But "use Win32::Process" will be OK. what's wrong?

You forgot to use diagnostics;

Bareword "THREAD_PRIORITY_BELOW_NORMAL" not allowed while "strict subs" in use at main2.pl line 466. Execution of main2.pl aborted due to compilation errors. (#1)
(F) With "strict subs" in use, a bareword is only allowed as a subroutine identifier, in curly brackets or to the left of the "=>" symbol. Perhaps you need to predeclare a subroutine?
Use strict warnings and diagnostics or die
## predeclare sub THREAD_PRIORITY_BELOW_NORMAL;
  • Comment on Re: require Win32::Process, barewords "THREAD_PRIORITY_BELOW_NORMAL" not allowed?
  • Download Code

Replies are listed 'Best First'.
Re^2: require Win32::Process, barewords "THREAD_PRIORITY_BELOW_NORMAL" not allowed?
by ikegami (Patriarch) on Sep 21, 2009 at 15:37 UTC
    The declaration's prototype has to match the definition's prototype.
    sub THREAD_PRIORITY_BELOW_NORMAL();

    Alternative:

    BEGIN { if ($^O eq 'MSWin32') { require Win32::Process; import Win32::Process; } } if ($^O eq 'MSWin32') { my $pid = Win32::Process::GetCurrentProcessID(); if (Win32::Process::Open(my $obj, $pid, 0)) { $obj->SetPriorityClass(THREAD_PRIORITY_BELOW_NORMAL); } }