Help for this page

Select Code to Download


  1. or download this
    foreach $j (@j) {
        alarm 2;
    ...
        next if $@ and $@ =~ /^timed out$/;
        # ^ You are checking for the exact string "timed out", but you sho
    +uld have /^timed out/ (without $ at the end), or, "timed out\n" in bo
    +th places (including the new-line character) because otherwise the me
    +ssage will include traces information from "die"
    }
    
  2. or download this
    foreach $j (@j) {
      print "Next Loop $j \n";
    ...
    # ^ Yeah... except if you didn't set alarm(0) above, and your script c
    +ontinues
    # to run and take longer than the alarm to complete, you'll eventually
    + have an
    # error stating "Terminating on signal SIGALRM(14)" and wonder why tha
    +t happened.
    
  3. or download this
    
    # First, the thing you want to timeout must be inside of an eval block
    +:
    ...
      # You had an actual error and not a timeout, so handle it:
      handle_error($@); # or just: die $@
    }