in reply to Calc distance between atoms in pdb file

Since I can not easily reproduce your problem, my best guess is that you either have an off-by-one error in your nested foreach loops or your arrays don't have as many elements as you think they do.

Before your foreach loops, you can check the number of elements in the arrays:

print scalar(@arrayx), "\n"; print scalar(@arrayy), "\n"; print scalar(@arrayz), "\n";

If that doesn't solve it, add print statements inside your foreach loops.

Another good practice is to check if your regex matches:

if (@line = $_ =~ m/^(.....).(.....).(....).(...)..(....)....(........ +)(........)(........)/) { $x = $line[5]; $arrayx[$num] = $x; # more code }

See also:

Replies are listed 'Best First'.
Re^2: Calc distance between atoms in pdb file
by stellaparallax (Novice) on May 01, 2012 at 00:32 UTC
    Thanks so everyone for taking the time to help a newbie out :). Makes sense now and it works yay!

      Can you provide me the full code please?