http://www.perlmonks.org?node_id=23486


in reply to Using Alarm to Handle Timing

It looks and works perfectly as far as I can tell. Its a bit hard-wired with that 5 seconds... but as a demo it works great :)

Is it possible to say $SIG{ALRM} = \&wake_up(5) by chance?

--awwaiid

Replies are listed 'Best First'.
RE: RE: Using Alarm to Handle Timing
by merlyn (Sage) on Jul 21, 2000 at 07:53 UTC
    Is it possible to say $SIG{ALRM} = \&wake_up(5) by chance?
    No. But you can pass a parameter by creating an anonymous subroutine:
    $SIG{MUND} = sub { &wakeup(5) };

    -- Randal L. Schwartz, Perl hacker

(chromatic) RE: RE: Using Alarm to Handle Timing
by chromatic (Archbishop) on Jul 21, 2000 at 01:05 UTC
    I'd considered making a global or package variable $timeout. It would be in scope for both the initialization and the signal handler.

    What I'm trying to do is manage my Jellybean objects better. Some of them need to flush their caches every few minutes while others ought to sync data to storage every now and then. Using an internal cron-like feature seems to be pretty elegant, but I don't want to segfault randomly if it's avoidable.