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]); } }