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

Andrew_Levenson has asked for the wisdom of the Perl Monks concerning the following question:

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}}