Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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}}

In reply to Parsing Guassian '03 Log Files by Andrew_Levenson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found