I note that the data you are interested are in the last part of the file. The reverse <$fh> is a pretty clunky way to read the file backwards but it works. If you can install File::ReadBackwards, it will be nicer, I think.
A slightly nicer version of your program:
foreach my $f (<*log>){ open my $fh,'<',$f; my @lines = reverse <$fh>; close $fh; next if ((shift @lines) !~ /Normal termination/); # Find the bond length. We assume this is built into the file name + my $R = $f; $R=~s/.log//; $R=~s/.*_//; my ($u,$edra,$edrb,@EDRvars,@Uvars); foreach my $line (@lines) { next unless ($line =~ m/^ \d/); last if ($line =~ m/^ Index/); (undef,undef,$u,$edra,$edrb) = unpack('A7A17A17A17A17',$line); push @Uvars, $u; push @EDRvars, $edra + $edrb; } # Print the outputs foreach my $i(0..$#Uvars){ print sprintf("%8.3E %12.6E %12.6E\n",$R,$Uvars[$i],$EDRvars[$ +i]); } }
In reply to Re^5: Making commond for large number of files
by GotToBTru
in thread Making commond for large number of files
by acrobat118
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |