| | |
Need help writing a perl script to parse multiple files
Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
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:
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:
#!/usr/bin/perl opendir(DIR,"."); @files = grep(/\.out$/,readdir(DIR)); closedir(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 }
Similar Threads
- perl script help (Perl)
- Multiple files Upload plz HelP (PHP)
- Repeat a script for multiple files (C++)
- Modifying a Perl script for multiple lines of html... (Perl)
- problems writing multiple files (Perl)
- Unix shell access from Perl script (Perl)
- perl script help re: scope/structure for noob (Perl)
- On execution of perl script, popup asks if i want to save or run this file (Linux Servers and Apache)
- Calculate the amount of time in the linux process using perl script (Perl)
| Thread Tools | Search this Thread |



