I'm new to perl and I'm writing a script to parse multiple Gaussian03 output files and extract certain pieces of data from them.

Ideally the script needs to print out the name of each file, look for (the last) SCF Energy, the Zero-point Energy and check if the job has converged (i.e. in the file the word 'YES' will appear with some other text on four consecutive lines).

So far the script prints out the filenames and the words "Energy =" and "Zero-point energy =" but without the values it is meant to insert. I've tested this with another script and it does print out the correct values, so I'm not sure why it's not working here.

Any help would be greatly appreciated.

Here is what I've been able to write so far:


@files = grep(/\.out$/,readdir(DIR));

foreach $file (@files)
 print "$file\n";

open FILE, "<$file";

 @entry = split(/\s+/,$line);
 $Energy = $entry[5];
 $ZPE = $entry[3];

while($line = <FILE>)
 if($line =~ /SCF Done/)
   print "Energy = $Energy\n";
 if($line =~ /Zero-point correction=/)
   print "Zero-point energy = $ZPE\n";
close FILE

Ah yes, thank you! It's printing out the required energies now.