ATOM 1279 C ALA 81 -1.925 -11.270 1.404 ATOM 1280 O ALA 81 -0.279 9.355 15.557 ATOM 1281 OXT ALA 81 -2.188 10.341 15.346 TER ATOM 1282 N THR 82 29.632 5.205 5.525 ATOM 1283 H1 THR 82 30.175 4.389 5.768 ATOM 1284 H2 THR 82 28.816 4.910 5.008 The code is: In the end it finds the maximum distance and its co ordinates my @points = (); open(IN, @ARGV[0]) or die "$!"; while (my $line = ) { chomp($line); my @array = (split (/\s+/, $line))[5, 6, 7]; print "@array\n"; push @points, [ @array ]; } close(IN); $max=0; for my $i1 ( 0 .. $#points ) { my ( $x1, $y1, $z1 ) = @{ $points[$i1] }; my $dist = sqrt( ($x1+1.925)**2 + ($y1+11.270)**2 + ($z1-1.404)**2 ); print "distance from (-1.925 -11.270 1.404) to ( $x1, $y1, $z1 ) is $dist\n"; if ( $dist > $max ) { $max = $dist; $x=$x1; $y=$y1; $z=$z1; }} print "maximum value is : $max\n"; print "co ordinates are : $x $y $z\n";