This should get you started. It doesn't give the results you want althought it seems to follow what you said you wanted. Must have misunderstood :-) I just read of the DATA filehandle so you will have to open your input and output files. We localise the change to $, to this block to save suprises. The last line data is in @last which we initialise to '' values to keep warnings happy

use strict; use warnings; { local $, = ','; # print will print CSV with this set to ',' my @last = (0) x 7; # initialize array to 0's while(<DATA>) { chomp; next if /^\s*$/; # skip blank lines my @data = split','; # split out line into an array my $deltatime = $data[2]-$last[2]; next unless $deltatime; # protect against illegal div zero my $bps = ( $data[5] + $data[6] ) / $deltatime; print @data[0,1,3,4], $bps, "\n"; # this will be CSV @last = @data; # remember last line content } } # Collected data csv: # date,time,epochSec,device,ifIndex,ifInOctets,ifOutOctets, __DATA__ 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,

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: control+data structures for multi-line math on csv by tachyon
in thread 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.