Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Perl's .. operator can do magic increments, but only for strings in the format /^[a-z]*[0-9]*$/i. But the problem you face here is that your increments must be by 1; not 1/100, not 5 minutes or 1 hour or whatever.

You'll have to somehow produce a range where increments are one, and scale them.

Plenty of people showed you how to do that with increments of 1/100, and here's a way to increment using time (in this exampel: increment in 5 minute intervals):

use POSIX qw(strftime); use Time::Local; my($from, $to, $incr) = ('13:00', '23:00', '0:05'); foreach($from, $to, $incr) { if(/^(\d+):(\d\d)(?::(\d\d))?$/) { $_ = ($1 * 60 + $2) * 60 + ($3 || 0); } } @range = map { strftime "%H:%M:%S", gmtime $_ } map $_*$incr, $from/$incr .. $to/$incr; $_ = join " ", @range; s/(.{1,70})(\s|$)/$1\n/g; print ;
Output:
13:00:00 13:05:00 13:10:00 13:15:00 13:20:00 13:25:00 13:30:00 13:35:00 13:40:00 13:45:00 13:50:00 13:55:00 14:00:00 14:05:00 14:10:00 14:15:00 14:20:00 14:25:00 14:30:00 14:35:00 14:40:00 14:45:00 14:50:00 14:55:00 15:00:00 15:05:00 15:10:00 15:15:00 15:20:00 15:25:00 15:30:00 15:35:00 15:40:00 15:45:00 15:50:00 15:55:00 16:00:00 16:05:00 16:10:00 16:15:00 16:20:00 16:25:00 16:30:00 16:35:00 16:40:00 16:45:00 16:50:00 16:55:00 17:00:00 17:05:00 17:10:00 17:15:00 17:20:00 17:25:00 17:30:00 17:35:00 17:40:00 17:45:00 17:50:00 17:55:00 18:00:00 18:05:00 18:10:00 18:15:00 18:20:00 18:25:00 18:30:00 18:35:00 18:40:00 18:45:00 18:50:00 18:55:00 19:00:00 19:05:00 19:10:00 19:15:00 19:20:00 19:25:00 19:30:00 19:35:00 19:40:00 19:45:00 19:50:00 19:55:00 20:00:00 20:05:00 20:10:00 20:15:00 20:20:00 20:25:00 20:30:00 20:35:00 20:40:00 20:45:00 20:50:00 20:55:00 21:00:00 21:05:00 21:10:00 21:15:00 21:20:00 21:25:00 21:30:00 21:35:00 21:40:00 21:45:00 21:50:00 21:55:00 22:00:00 22:05:00 22:10:00 22:15:00 22:20:00 22:25:00 22:30:00 22:35:00 22:40:00 22:45:00 22:50:00 22:55:00 23:00:00

Tweaking the format spec for strftime you can produce a different time format.


In reply to Re: Decimal Array range by bart
in thread Decimal Array range by packetstormer

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 avoiding work at the Monastery: (7)
    As of 2014-08-29 08:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (277 votes), past polls