Hey guys - sorry for the long title. Long story short, I'm new to Perl (so new, in fact, that I have yet to write a single line). But it's good to learn, right?

This is the initial problem I've been presented with:

I need to locate the maximum value in the 2nd column of a file. I then need to subtract off a value at an initial time (given in the first column). The initial time is 3000 seconds, but in no file is the value "3000" ever presented. Rather, we take the first value which transitions from 2999 to 3000. This needs to be done for quite a number of files in a directory.

I then need to export these differences to a document.

Here's an example of what I'd like to do with some data:

2999.98 280 2999.99 281 3000.01 280 3000.02 290 3000.03 300 3000.04 310 ... 4250.01 300 4250.02 290

The program would take 310 from column 2, then go to column one and find the value "3000.01", take the value of 280 in that row, and subtract it from 310. It would then write the difference (30) to another file. After it's finished with every file in a directory, it would save that new file to a separate directory.

Now, I've got plenty of experience in other languages to be able to catch on quickly (and honestly, I'd like to do it in another language, but my heads are tied on my software of choice).

Let me know, guys!

As a side note, I have the "Learning Perl" book from Schwartz, Phoenix, and Foy. If anyone is extremely familiar with this book and offers a response, I'd like to know which sections might be particularly relevant to the coding solution.

Thanks everyone!


In reply to New to Perl - locating max, subtracting initial, printing output, all across several files in differing directories by jtrousde

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.