#! perl -slw
use strict;
use List::Util qw[ sum ];
BEGIN{ @ARGV = map glob( $_ ), @ARGV }
my %stats;
while( <> ) {
next unless m[^ATOM];
my @fields = unpack 'a6 a5 a3 a3 a4 x2 a3 x4 a8 a8 a7 a7 a6 a12', $_;
# print join'|', @fields;
push @{ $stats{ $fields[ 4 ] } }, $fields[ 10 ];
}
printf "%3s : %.3f%%\n", $_,
sum( @{ $stats{ $_ } } ) / @{ $stats{ $_ } }
for sort keys %stats;
####
theScript.pl /path/to/*.pdb
##
##
## For windows; something similar is possible on *nix
for %i in (\path\to\*.pdb) do @theScript.pl \path\to\%i