Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: How to calculate values based on date / time stamp?

by InfiniteSilence (Curate)
on Jan 30, 2012 at 01:47 UTC ( #950683=note: print w/replies, xml ) Need Help??

in reply to How to calculate values based on date / time stamp?

Couple of pieces of advice:

  • Stop parsing delimited strings by hand. You can use Text::CSV
  • even for something with a different separator as the perldoc says, "The module accepts either strings or files as input and can utilize any user-specified characters as delimiters, separators, and escapes so it is perhaps better called ASV (anything separated values) rather than just CSV.'
  • Try perldoc -q switch instead of those if statements.
  • For your question, provided you have an ordered set of times, I would quantize them to multiples of five and then aggregate them in a hash. For instance:
    linux~> perl -e 'my @quant = (); my @times = qw|12 14 21 27 30|; sub r +ound{while (@_[0]%5 != 0){@_[0]++}; return @_[0]}; for(@times){print +round($_), qq|\n|};'

Celebrate Intellectual Diversity

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950683]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2018-01-19 23:58 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (226 votes). Check out past polls.