Thank you very much, but unfortunately, I need it to work in such a way that I call the script/program, feed it an input filename and an output filename, and have it work its magic. Each file is of an undetermined length, with sections that need to be parsed f undetermined length, as each file represents a different chain-length of the molecule.
Sorry that I didn't specify that earlier.
C(qw/74 97 104 112/);sub C{while(@_){$c**=$C;print
(map{chr($C!=$c?shift:pop)}$_),$C+=@_%2!=1?1:0}}
| [reply] [d/l] |
Well, I couldn't do it all for you - what would you do with all the time you saved?
You may find help in dealing with the file issues in replies to the thread File read and strip ;).
Perl is environmentally friendly - it saves trees
| [reply] |
Thanks, GF. You've been a great help time and again. :)
C(qw/74 97 104 112/);sub C{while(@_){$c**=$C;print
(map{chr($C!=$c?shift:pop)}$_),$C+=@_%2!=1?1:0}}
| [reply] [d/l] |
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}}
| [reply] [d/l] [select] |