In your main loop, you check that the time difference is exactly 1800, 3600, etc. seconds. This is a condition that is only true for one second. And since you are sleeping for a full second, it seems conceivable that if the system is very busy, your process may not get woken up from its sleep in that one-second window of opportunity.

I might rewrite the loop in the following way to be sure that the action is triggered the first time the script is woken up after a target number of seconds.

sleep 1 until time - $llent->ll_time >= 1800; passive_pop("Thirty minutes"); sleep 1 until time - $llent->ll_time >= 3600; passive_pop("One hour"); sleep 1 until time - $llent->ll_time >= 5400; passive_pop("Ninety minutes"); sleep 1 until time - $llent->ll_time >= 7200; passive_pop("Two hours"); tattle_tail();
Or to be even fancier and extensible-er:
my %actions = ( 1800 => sub { passive_pop("Thirty minutes"); }, 3600 => sub { passive_pop("Sixty minutes"); }, 5400 => sub { passive_pop("Ninety minutes"); }, 7200 => sub { passive_pop("Two hours"); tattle_tail(); }, # 8000 => sub { disable_network_interface(); }, # 9999 => sub { self_destruct(); } ); for my $duration (sort {$a <=> $b} keys %actions) { sleep 1 until time - $llent->ll_time >= $duration; $actions{$duration}->(); }
Also, it appears that your code as written will loop forever. This may be fine if your KDE autostart things get automatically killed when he logs out, but is something to consider.

blokhead


In reply to Re: Reminder for KDE Kid by blokhead
in thread Reminder for KDE Kid by KennV

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.