Greetings, monks! It's been a while.I haven't been to the site, or even really thought about perl in a while, as I've been off having adventures in university-land.
Now, i'm doing some undergraduate research for theoretical chemistry, and find myself working with absolutely monstrous log files from the absolutely ingenious Gaussian '03. Today, my research mentor asked me to manually trudge through the log files to compile a list of bond lengths between certain atoms in the molecule I'm working on, but I realized that using perl could save me days worth of eye-straining work. Hooray! Unfortunately, I've grown a bit rusty.
What I need to do is create a script that reads in a log file, searches for an area of text between "Optimized Parameters" and "GradGradGradGrad", and then read each line and rip out the value and see if it fits in the range I'm working with. I know a regular expression will work wonders, but I am, as I said, really very rusty. If the individual lines I need to read look something like this example:
! hc2 1.1136 -DE/DX = 0.0 !
and a hypothetical 4 entry log looks something like this:
----------------------------
! Optimized Parameters !
! (Angstroms and Degrees) !
---------------------- -------------------
+-----------------------------------------------------
! Name Value Derivative information (Atomic Units)
+ !
---------------------------------------------------------------------
+---
! hc2 1.1136 -DE/DX = 0.0
+ !
! nc3 1.3392 -DE/DX = 0.0
+ !
! nch3 117.4979 -DE/DX = 0.0
+ !
! hn4 0.9929 -DE/DX = 0.0
+ !
----------------------------------------------------------------------
+--
GradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGr
+adGrad
How can I grab the numbers under 'value,' keeping in mind that there may be lines looking like this in other sections of the incredibly dense log files?
Thanks a million in advanced.
C(qw/74 97 104 112/);sub C{while(@_){$c**=$C;print
(map{chr($C!=$c?shift:pop)}$_),$C+=@_%2!=1?1:0}}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.