Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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

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, 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
  • 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (9)
    As of 2018-06-20 22:11 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (117 votes). Check out past polls.