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

mishimakaz has asked for the wisdom of the Perl Monks concerning the following question:

Hey all, I am a PERL newbie trying to create a script to calculate the distance between all HIS/ASP residues and a single Zinc atom embedded into a protein.

#!/usr/bin/perl -W use strict; use warnings; #subroutines for calculations sub distanceAB { my $distance = 0; my $Ax = substr($_[0], 30, 8) + 0; my $Ay = substr($_[0], 38, 8) + 0; my $Az = substr($_[0], 46, 8) + 0; my $Bx = substr($_[1], 30, 8) + 0; my $By = substr($_[1], 38, 8) + 0; my $Bz = substr($_[1], 46, 8) + 0; $distance = sqrt(($Ax - $Bx)**2 + ($Ay - $By)**2 + ($Az - $Bz) +**2); return sprintf("%4.2f", $distance); } #open files for calculations and modify distance cutoff for target res +idues my $input=$ARGV[0]; my $num = 0; my $i = 0; open IN, "<$input" or die "can't open .pdb"; my @pdblines = (); while (<IN>) { for ( @pdblines) { #chomp $pdbline; if (my $pdbline =~ /ZN1 LG1 X/) { my $ZNline = $pdbline; next; } #find xyz coordinates for other atoms and store in array if (my $pdbline =~ /^ATOM.*(OD2 ASP|NE2 HIS)/) { my $Atomline = $pdbline; my $resname = substr($pdbline, 16, 3); my $resnumber = substr($pdbline, 22, 3); #calculate Zn to each atom distance my $Zndistance=distanceAB(my $ZNline, $Atomline); if (my $Zndistance < 2.5) { print "$Zndistance \n"; print "$resname $resnumber \n"; print "Coordinator $num \n"; } } ++$num; } }

When I run the code, I get a lot of "Use of initialized value" errors, such as

Use of uninitialized value $Znx in array element at ./getRESZNdistance.pl line 58, <IN> line 2863.

Use of uninitialized value $Znz in array element at ./getRESZNdistance.pl line 58, <IN> line 2863.

Basically when the script encounters lines that do not contain /OD2 ASP/ or /NE2 HIS/ it runs into an error from what I can see.

Any suggestions?