Next | You can't get there from here | 26 |
What's wrong with this?
use Timeout;
sub halts { my ($source_code, $input) = @_; my $function = eval $source_code;
# Run the function for at most an hour my $finished = with_timeout 3600, sub { $function->($input) };
if ($finished) { return 1 } # It finished within an hour else { return 0 } # It was still running after an hour }
continued...
Next | Copyright © 2005 M. J. Dominus |