I'd try something like this, in the assumption that all lines have the same number of numerical columns:
my @prev; local($\, $,) = ("\n", " "); while(<DATA>) { my($date, $time, @current) = split " "; if(@prev) { print $date, $time, map { $current[$_] - $prev[$_] } 0 .. $#cu +rrent; } @prev = @current; } __DATA__ 02/02/2007 00:00:00 719267027 719244316 719233953 719240015 02/03/2007 00:00:00 720375777 720336674 720325633 720329849 02/04/2007 00:00:00 721640280 721640267 721522690 721552815 02/05/2007 00:00:00 722297206 722297203 722297203 722297206

(written so it uses the enclosed test data)

Result:

02/03/2007 00:00:00 1108750 1092358 1091680 1089834 02/04/2007 00:00:00 1264503 1303593 1197057 1222966 02/05/2007 00:00:00 656926 656936 774513 744391

To turn this into something that reads from a file instead of from the list of data near the end of the script, replace the <DATA> with <> and pass the file name on the command line.


In reply to Re: processing columns of text by bart
in thread processing columns of text by sitnalta

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.