Here's a working example of how to get the current time and how to make your Perl script wait a specified amount of time. You should be able to do the rest on your own. :-)
#!/usr/bin/perl -w use strict; my %TRUE_FALSE = ( '1' => 'True', '0' => 'False', ); my %DAY_OF_WEEK = ( '0' => 'Sunday', '1' => 'Monday', '2' => 'Tuesday', '3' => 'Wednesday', '4' => 'Thursday', '5' => 'Friday', '6' => 'Saturday', ); { &displayTime(); &waitAwhile(3); &displayTime(); } exit; sub displayTime { my $nowsse = time; my ($nowsec,$nowmin,$nowhou,$nowdom,$nowmon,$nowyea,$nowdow,$nowdo +y,$nowdst) = localtime($nowsse); $nowyea += 1900; $nowmon++; print "---------------------------------------------\n"; my $nowDisplay = sprintf "%04d-%02d-%02d\@%02d:%02d:%02d", $nowyea, $nowmon, $nowdom, $nowhou, $nowmin, $nowsec ; print " Time right now: $nowDisplay\n"; print " Day of Week: $DAY_OF_WEEK{$nowdow}\n"; print " Day of Year: $nowdoy\n"; print "Daylight Savings: $TRUE_FALSE{$nowdst}\n"; print "---------------------------------------------\n"; } sub waitAwhile { my ($waitSeconds, @dummy) = @_; if (!defined $waitSeconds) { $waitSeconds = 0; } if ($waitSeconds <= 0) { $waitSeconds = 3; } print "Waiting $waitSeconds seconds\n"; sleep $waitSeconds; } __END__ C:\Steve\Dev\PerlMonks\P-2013-07-18@1650-Time-Computation>perl timeCom +putation.pl --------------------------------------------- Time right now: 2013-07-18@17:03:10 Day of Week: Thursday Day of Year: 198 Daylight Savings: True --------------------------------------------- Waiting 3 seconds --------------------------------------------- Time right now: 2013-07-18@17:03:13 Day of Week: Thursday Day of Year: 198 Daylight Savings: True ---------------------------------------------
Have fun!

In reply to Re: Script to poll every hour by marinersk
in thread Script to poll every hour by sidsinha

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.