[San-Diego-pm] Wrangle module version?

Reuben Settergren ruberad at gmail.com
Tue May 10 14:47:43 PDT 2011

Hello Mongers,

I have what seems like it should be a simple problem (and it probably is!),
but I'm not finding the simple solution, so I'm hoping somebody can give me
the right answer off the top of their head.

So the group I work with shares a perl script to run multi-hour builds (of
C++, on windows boxes, with visual studio 9). Usually we try to rebuild the
whole shebang overnight, and then work on it all day. But sometimes we have
to build during the day, and the computer can bog down.

So yesterday I added this bitchin little tweak to allow the script to demote
its own windows priority to "Below Normal", which in turn governs the
priority of all the build tasks it spawns. Suddenly, it's a lot easier to
get work done while the computer is building. Yay.

But, I discovered today that not all of us developers have the same install
of ActiveState (and it's not possible to mandate them to all upgrade to
5.10), and older versions of Win32::Process do not offer the symbols
because win2K or pre-win2K did not have those priorities), so they cannot

    use Win32::Process qw[ BELOW_NORMAL_PRIORITY_CLASS

and the perl script borks.

What I could do is modify the script so that the only possible
priority-switching option is to change to LOW.

What I'd rather do is allow every user access to every priority that their
Win32::Process makes available to them. Is there a perl statement that will
tell me whether Win32::Process is able to export the symbols I want, without
actually trying to import them and killing the script?

For reference, the trivial script below works for me, but not for the
outdated. If this could be made to detect whether the symbols are available,
and switch to low/high if they are not, that would solve my problem.

use Win32::Process;

my $pid = Win32::Process::GetCurrentProcessID();
print "PID is $pid\n";

$i = 100;
$dt = 5;
while ($i) {
  print "Sleeping for $dt seconds; $i\n";
  sleep $dt;

  my $proc;
  if (Win32::Process::Open($proc, $pid, 0)) {
    my $class;
    print "Priority class is $class\n";
    if ($i%2) {
      print "Changing class to BELOW NORMAL\n";
    } else {
      print "Changing class to ABOVE NORMAL\n";

  } else {
    print "Can't find myself as PID=$pid\n";

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/san-diego-pm/attachments/20110510/63e364d5/attachment.html>

More information about the San-Diego-pm mailing list