[comp.lang.perl] trouble setting alarm

barn@convex.com (Tim Barney) (03/26/91)

Usually I have trouble getting up when my alarm goes off. Today, I'm
having a lot of trouble just trying to set it! I keep getting

syntax error in file e12 at line 4, next 2 tokens "alarm  60"
Execution aborted due to compilation errors.

Where is my mistake? It seems to me to be according to The Book.......
tim_

#!/usr/bin/perl
$SIG{'ALARM'} = 'sighandler';
# also tried alarm(60); , $n = alarm(60);, and $n = 60;alarm($n);
alarm  60 ;

for ($i=0;$i<200000;$i++) { $j = $i-1;}
print "complete \n";
exit(0); 

sub sighandler {
   local($sig) = @_;
   print "caught it now! $sig\n";
   exit(1);
}

lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) (03/29/91)

In article <1991Mar25.172223.28322@convex.com> barn@convex.com (Tim Barney) writes:
: Usually I have trouble getting up when my alarm goes off. Today, I'm
: having a lot of trouble just trying to set it! I keep getting
: 
: syntax error in file e12 at line 4, next 2 tokens "alarm  60"
: Execution aborted due to compilation errors.
: 
: Where is my mistake? It seems to me to be according to The Book.......

The Book purports to document only version 4.0.  alarm was a fairly late
addition to 3.0, so it's probably not in your installed version.

Larry