Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 rifling through the Monastery: (4)
As of 2016-02-09 06:23 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (305 votes), past polls