I've written perl code that collects interface packet counts via SNMP.   So far, so good.   Now I'm asking for y'alls wisdom on getting the *real* data out of the following csv.

What I need to do goes something like this (in english):

Read the first and second lines
    deltaTime2 = epochSec2 - epochSec1
    Bps2 = (ifInOctets2 + ifOutOctets2)/deltaTime2
Read the second and third lines
    deltaTime3 = epochSec3 - epochSec2
    Bps3 = (ifInOctets3 + ifOutOctets3)/deltaTime3
Read the third and fourth lines
    deltaTime4 = epochSec4 - epochSec3
    Bps3 = (ifInOctets4 + ifOutOctets4)/deltaTime4

Lather, rinse, repeat...

In a past life, I'd have used Excel for the calculations {oh, the shame} but now I'd *really* like to do this in a Perlish manner.     Doing the simple arithmetic in Perl is easy.   I imagine the control code might involve split() and a LoL, but am quite unclear on where to start.   Any clueful monks care to point me in a good direction?
    cheers,
    Don
    striving toward Perl Adept
    (it's pronounced "why-bick")

Collected data csv:

date,time,epochSec,device,ifIndex,ifInOctets,ifOutOctets, 2001-08-10,18:15:00,997485300,boston,141,1916238333,2743654663, 2001-08-10,18:18:12,997485492,boston,141,1917535505,2744657633, 2001-08-10,18:21:23,997485683,boston,141,1919320447,2747461877, 2001-08-10,18:24:34,997485874,boston,141,1921869420,2748722088, 2001-08-10,18:27:46,997486066,boston,141,1925884600,2764661750, 2001-08-10,18:30:57,997486257,boston,141,1929925399,2766849525, ...

Desired output csv:

date,time,,device,ifIndex,Bps, 2001-08-10,18:15:00,boston,141,, 2001-08-10,18:18:12,boston,141,11649, 2001-08-10,18:21:23,boston,141,24969, ...

In reply to control+data structures for multi-line math on csv by ybiC

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!
  • 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, details, 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, summary, 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.