Something like:

use strict; use warnings; my $file = <<FILE; ---------------------------- ! 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 FILE open my $inFile, '<', \$file; my $valueStart; my $valueLength; my $min = 1.0; my $max = 2.0; while (<$inFile>) { next unless m/Optimized Parameters/ .. m/GradGradGrad/; next unless $valueLength or /^(.*?Name)(\s*Value)/; if (! $valueLength) { $valueStart = length $1; $valueLength = length $2; next; } my $value = substr $_, $valueStart, $valueLength; next unless $value =~ /^\s*[+-]?\d+(\.\d*)?\s*$/; next if $value < $min or $value > $max; print $_; } close $inFile;

Prints:

! hc2 1.1136 -DE/DX = 0.0 + ! ! nc3 1.3392 -DE/DX = 0.0 + !

Perl is environmentally friendly - it saves trees

In reply to Re: Parsing Guassian '03 Log Files by GrandFather
in thread 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":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.