jtrousde has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: New to Perl - locating max, subtracting initial, printing output, all across several files in differing directories
by choroba (Cardinal) on Feb 04, 2015 at 14:50 UTC | |
|
Re: New to Perl - locating max, subtracting initial, printing output, all across several files in differing directories
by blindluke (Hermit) on Feb 04, 2015 at 17:49 UTC | |
by jtrousde (Initiate) on Feb 04, 2015 at 19:09 UTC | |
|
Re: New to Perl - locating max, subtracting initial, printing output, all across several files in differing directories
by Laurent_R (Canon) on Feb 04, 2015 at 19:52 UTC | |