http://www.perlmonks.org?node_id=1065330


in reply to calculate distance between atoms and a target atom

Don't use this sort of construct:

if ($pdbline =~ /OD2 ASP/ or /NE2 HIS/)

You are testing 2 possibilities here. The first one is $pdbline =~ /OD2 ASP/ which may be fine, but the second one is /NE2 HIS/ which by default will test $_ which is probably not what you want. Either combine the 2 regular expressions into 1 (left as an exercise) or test them individually like this:

if ($pdbline =~ /OD2 ASP/ or $pdbline =~ /NE2 HIS/)

The "Use of uninitialized value" reports you see are warnings, not errors. However, the fact that they are presented to you indicates that you are attempting to do something with an uninitialised value which is usually not what you intend.

In this specific case, your references to items like $x1[$Znx] on line 58 will give that if the $Znx is uninitialised. You will need to trace through the logic to see how that might happen and correct it.

Best advice is:

Best of luck with the rest of it.