Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

There's some issues with is_poll_time(). You're looping through all hours except one: 1 to 24 won't pick up 00:20. As it looks like you want all hours, that loop is entirely redundant; all you need is:

sub is_poll_time { for (@_) { my $t = gmtime $_; return 1 if $t->min == $poll_minute; } return 0; }

If you had needed that loop, it would have better written more like Perl and less like C. Consider whether you think this is clearer:

for my $poll_hour (0 .. 24) { # Process $poll_hour here }

Assigning to @$_[0] and @$_[1] is a poor choice: you're altering the original data. I question whether doing that is necessary here; however, as a general rule of thumb, assign to a new variable rather than altering the original data.

Pulling out parts of date/time strings with substr and doing various arithmetic calculations to generate seconds, minutes, etc. is prone to errors and, as far as I can see, extra work you don't need to do. I repeat what I said in my initial reply:

"Check the Time::Piece documentation to see how I've used it and for ways to format the output ..."

Use indentation to show the logical structure of your code. This makes it easier for everyone (including yourself) to read and follow. It also makes it less prone to errors and, when errors do exist, easier to find them. You only have a small script so uneven and inconsistent identation was not a huge impediment; when you start writing more complex code it will make a big difference. See "perlstyle - Perl style guide" for hints and tips in this area.

Please do not post vast swathes of data such as you've done here. Only post enough to illustrate whatever point you're making. If you do consider it necessary to post pages of data, use <readmore> of <spoiler> tags which are explained here: "Writeup Formatting Tips".

-- Ken


In reply to Re^5: Epoch based parser by kcott
in thread Epoch based parser by spikeinc

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (4)
    As of 2014-08-30 11:18 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (293 votes), past polls