The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sub::Retry - retry $n times

SYNOPSIS

    use Sub::Retry;
    use LWP::UserAgent;

    my $ua = LWP::UserAgent->new();
    my $res = retry 3, 1, sub {
        $ua->post('http://example.com/api/foo/bar');
    };

DESCRIPTION

Sub::Retry provides the fuction named 'retry'.

FUNCTIONS

retry($n_times, $delay, \&code)

This function calls \&code. If the code throws exception, this function retry $n_times after $delay seconds.

Return value of this function is the return value of \&code. This function cares wantarray.

AUTHOR

Tokuhiro Matsuno <tokuhirom AAJKLFJEF GMAIL COM>

LICENSE

Copyright (C) Tokuhiro Matsuno

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.