I ended up hacking this together when I got into the lab this afternoon. It's ugly, and probably inefficient, but it is entirely within my skillset and it works beautifully for what I need it to do (save for one file, which for some reason gets printed in triplicate, but that is just one case).
#!/usr/bin/perl
use strict;
use warnings;
# Parse Gaussian '03 output files
# for the lengths of the bonds
# in Diaminopolymethine Dyes
# strictly between Carbon and Nitrogen
# or Carbon and Carbon
my $infile, my $outfile;
my @inlog, my @inlog_n, my @logged;
chomp($infile = <>);
chomp($outfile = <>);
open FILE, "<$infile";
while(<FILE>)
{
push @inlog, $_;
}
close FILE;
for(@inlog)
{
push @inlog_n, grep( /^\s?!{1}?\s*(c|n)/, $_);
}
@inlog = grep( !/h|c{3}?|nc{2}?|(estimate)|c{2}?n{1}?/, @inlog_n );
pop @inlog_n for @inlog_n;
@inlog_n = map{ split( /\s/, $_) } @inlog;
pop @inlog for @inlog;
for(@inlog_n)
{
push @logged, $_ if $_=~/\d/ && $_!~/[a-zA-Z]/;
}
open LOG, ">$outfile";
for(@logged)
{
print LOG "$_\n" if $_>=1;
}
close LOG;
Thanks again for the help!
C(qw/74 97 104 112/);sub C{while(@_){$c**=$C;print
(map{chr($C!=$c?shift:pop)}$_),$C+=@_%2!=1?1:0}}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.