My Async::Event::Interval may be of use here. It's exceptionally rudimentary in what it does.

This software is designed to run your async event at specific intervals (every number of seconds). Here is a very brief example:

use warnings; use strict; use Async::Event::Interval; my $event = Async::Event::Interval->new( 2, # number of seconds between execs \&callback, # code reference, or anonymous sub 'https://google.ca' # parameters to the callback ); $event->start; sleep 3; # your app does other stuff here sub callback { my ($url) = @_; print "$url\n"; }

If you do only want it to run a single time, kill the proc after it does its work:

sub callback { my ($url) = @_; print "$url\n"; kill 9, $$; }

Then, if you want to spin it up manually later, just call $event->start again. If you need more arguments, append them in list form to the end of the new() call.


In reply to Re: Advice: Async Options for fire-and-forget subroutine by stevieb
in thread Advice: Async Options for fire-and-forget subroutine by mwb613

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.