http://www.perlmonks.org?node_id=973606


in reply to Re: File Parsing
in thread File Parsing

Thank you for the replies. To complicate this a bit more, if the file looks like this and I need to parse out the last two occurances of the search string, skip three lines in each and then only print the lines of data that have 0.150 in the first field and -45.00 in the third field, what would I add? Thanks Again!

9 FAILURE CRITERIA PER PLY FAILURE CRITERIA PER PLY DIST ANGLE PLY FAILURE NUMBERS 1 2 SHEAR 0.000 0.00 -45.00 0.238 0.282 -1.459 0.000 0.00 0.00 0.971 1.369 0.004 0.150 5.00 -45.00 0.475 0.142 -1.585 0.150 5.00 0.00 1.003 1.531 -0.274 FAILURE CRITERIA PER PLY DIST ANGLE PLY FAILURE NUMBERS 1 2 SHEAR 0.000 0.00 -45.00 0.247 0.293 -1.514 0.000 0.00 0.00 1.008 1.422 0.004 0.150 5.00 -45.00 0.493 0.147 -1.645 0.150 5.00 0.00 1.042 1.589 -0.284

Replies are listed 'Best First'.
Re^3: File Parsing
by thundergnat (Deacon) on Jun 01, 2012 at 14:30 UTC
    if the file looks like this and I need to parse out the last two occurances of the search string, skip three lines in each and then only print the lines of data that have 0.150 in the first field and -45.00 in the third field, what would I add?

    <smartass>"Code to do that" seems like an obvious answer.</smartass>

    Honestly though, there is code in my example above that demonstrates splitting into fields and checking for equality isn't a very obscure operation. Try it yourself and if you can't figure it out, show us your code that doesn't work. You'll get less sarcastic answers if you demonstrate that you've made a little effort.