Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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

Comment on Re: How to calculate values based on date / time stamp?
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950683]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2015-11-27 06:44 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (719 votes), past polls