Sub::Timebound - Perl extension for timebound computations
use Sub::Timebound; sub fun { my $i = shift; if ($i =~ /7$/) { die "Simulated internal error\n"; } while ($i) { $i--; } return "All is well"; } my $x = timeboundretry(10, 3, 5, \&fun, 10); ### Returns { value => '...', status => 0(FAILURE)/1(SUCCESS) } ### 'value' is the return value of fun() if ($x->{status}) { # SUCCESS $x->{value} } else { # FAILURE }
Module exports "timeboundretry" - this is a wrapper that watches a function call. my $x = timeboundretry([TimeAllocated], [NumberOfAttempts], [PauseBetweenAttempts],[CodeRef],[Param1], [Param2], ...); [TimeAllocated] - Seconds allocated to [CodeRef] to complete [NumberOfAttempts] - Number of attempts made to [CodeRef] [PauseBetweenAttempts] - Seconds to wait before making subsequent attempts [CodeRef] - Reference to subroutine [Param1]... - Parameters to subroutine
timeboundretry()
Proc::Reliable is a similar module that addresses external processes
Ramana Mokkapati, E<lt>mvr@cpan.org<gt>
Copyright (C) 2005 by Ramana Mokkapati <mvr@cpan.org> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.
To install Sub::Timebound, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Timebound
CPAN shell
perl -MCPAN -e shell install Sub::Timebound
For more information on module installation, please visit the detailed CPAN module installation guide.