Many thanks to Rob for doing this!
      I do in fact have perl 5.6.   I typed in Rob's modifications to my code, 
hoping that perhaps all I needed was  say, the "use warnings;" line of his.   
But it still failed.  My error  message includes "The Unsupported function 
alarm function is unimplemented".
      So I'd like to get the later version of perl.  That seems to be the 
thing.  I mean, Rob gets the results I want and what  other difference is 
there?  I  have some general fears and questions about that though and if 
anyone can allay  my concerns I'd be grateful and plunge ahead.   I have a 
bunch of other programs I've written and find useful which work  fine in perl 
5.6.  Will they all still  work if I switch?  More generally  speaking, will 
all that I know about perl (scant as it is) still apply?  I mean, while loops 
are still while loops,  foreach is still done the same way, right?   There may 
be new possibilities available to me in the later version that  I'm not hip to, 
but no old programming possibilities have been removed, right?
          
  Secondly, how do I switch exactly?  I went to that url and saw a bunch of 
links for downloads, but I  wouldn't know which distribution and platform to 
choose.  I assume one of the Windows ones, but x86 or  x64, and AS package or 
MSI?  And once I  click the proper link, are there other things I'll need to 
do?  Must I remove the old version?   Must I reset something?  I'm very  much a 
computer novice, probably much more than you all would think given that  I can 
write code like that below, and I fear there is some other step or two  beyond 
clicking that download button which is so utterly obvious to everyone  that it 
doesn't get mentioned, but I don't know to do it, and thus my whole  attempt to 
get an updated version will fail.
          And thirdly, just to be sure, can I mention again that I'm  using 
Windows ME - that strikes me as another possible difference between Rob  and I. 
 (I assume Rob's using XP.)
          Thank you Thank you Thank you.
      Chris
        
Sisyphus <[EMAIL PROTECTED]> wrote:  
----- Original Message ----- 
From: Chris Rodriguez
.
.
for($number = 1; $number < 5; $number +=1) {
  $ProgramName = "infinite" . $number . ".pl";
  eval {
    local $SIG{ALRM} = sub { die "$ProgramName timed out\n" };
      alarm 9;
      require $ProgramName or die "Require failed\n";
      alarm 0;
  };
  print $@;
  if($@) {
    if($@ =~ /timed out/) {
      print "timeout\n"; # timeout
    } else {print "some other error\n"; # some other error
   }
  }
}

If the alarm function now works on Windows, why doesn't this code give me 
the results I expect?  Might it matter than I'm using Windows ME?  What 
about my version of PERL?  It's the one from the CD that came with that 
book.  5.6 I think - I can check if it matters.

###########################################

I think it does matter. I didn't check to see what happens when I try to run 
the above code on perl 5.6 (though I expect it fails), but there's certainly 
no problem with that on perl 5.8.8.

I created 4 scripts along the lines you suggested, and ran the following 
(slightly modified version of your) code:

-------------
use warnings;

for($number = 1; $number < 5; $number +=1) {
  $ProgramName = "infinite" . $number . ".pl";
  eval {
    local $SIG{ALRM} = sub { die "$ProgramName timed out\n" };
      alarm 9;
      require $ProgramName or die "Require failed\n";
      alarm 0;
  };
  print "Error message: *** $@ ***\n";
  if($@) {
    if($@ =~ /timed out/) {
      print "timeout\n"; # timeout
    } else {print "some other error\n"; # some other error
   }
  }
}
--------------

For me that outputs:

--------------
C:\_32\pscrpt>perl try.pl
Error message: ***  ***
Error message: ***  ***
Error message: *** infinite3.pl timed out
Compilation failed in require at try.pl line 8.
 ***
timeout
Error message: ***  ***
--------------

The first 2 lines of output appear almost immediately, and the rest appears 
9 seconds later.

That's pretty much as expected. However, I wasn't expecting that 
"Compilation failed in require at try.pl line 8.\n" would be concatenated 
onto "infinite3.pl timed out\n". On further reflection, I *think* it's 
correct and expected behaviour ... but I'm not necessarily right about that 
aspect :-)

Certainly, if you comment out that SIGALRM handler subroutine, then the 
output is as expected:

--------------
C:\_32\pscrpt>perl try.pl
Error message: ***  ***
Error message: ***  ***
Terminating on signal SIGALRM(14)
--------------

Again, the first 2 lines appear instantly, the third 9 seconds later.

I recommend you switch to the latest perl - you can get it from:
http://activestate.com/store/download.aspx?prdGUID=81fbce82-6bd5-49bc-a915-08d58c2648ca

And yes, I *am* running in what's commonly referred to as the DOS shell - 
though it's actually the cmd.exe shell (which has nothing to do with DOS).
Which shell are you using ?

Cheers,
Rob





 
---------------------------------
Sucker-punch spam with award-winning protection.
 Try the free Yahoo! Mail Beta.
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to