Astro-IRAF-CL
view release on metacpan or search on metacpan
$iraf->exec(command => 'print "hello"',
timeout => 2,
timeout_handler => sub {print $command . " timed out\n"; $timed_out = 1});
The script can then see from the $timed_out variable that the timeout has occured and can clean up accordingly and move on. Here i have used an anonymous subroutine instead of a reference to a subroutine as it is fairly small.
=item *
B<EOF/Death handling>
This is the situation when the whole CL interpreter has died, this is a not uncommon occurence with IRAF as some packages are not quite as robust as they should and the CL is quite fragile in certain situations. If have a large number of jobs to do y...
$iraf->cd($workdir);
$iraf->exec(command => 'print "hello"',
death_handler => sub {$iraf->restart(); $iraf->cd($workdir)});
=item *
B<CL error handling>
A CL error is encountered when the command executed returns with the ERROR code and a message as to what happened. This is dealt with in the same way as the timeout handler above:
( run in 0.660 second using v1.01-cache-2.11-cpan-b16cb0d3907 )