in reply to confused with distances

If there are going to be many helices, I'd use a hash of hashes, where each element is an array reference:

$atoms{HELIX1}{A} = [ ( -1.115, 8.537, 7.075)];
#!perl use warnings; use strict; my %atoms; my $key; while(<DATA>) { chomp; next if /^\s*$/; if(/^[^\s]/){ s/:.*$//; $key = $_; print "\$_: $_\n","\$key: $key\n"; } else{ s/^\s*|\s*$//g; (my $sub, my $idx,my $x, my $y,my $z) = split(/\s+/,$_,5); print "\t\$_: $_\n","\t\$sub: $sub\n\txyz",join(", ", ($x, $y, + $z)),"\n"; $atoms{$key}{$sub} = [ (+$x, +$y, +$z)]; # force numerical con +text } } __DATA__ HELIX1: x y z A 1 -1.115 8.537 7.075 B 2 -2.745 5.280 7.165 C 3 -0.777 3.267 7.329 D 4 1.610 5.225 10.885 E 5 0.296 5.263 10.912 HELIX2: K 1 -0.696 13.041 22.357 L 2 1.152 11.081 23.082 M 3 2.200 17.590 18.424

While the above code is, doubtless, is less elegant and otherwise inferior to what those monks more fluent in Perl than I would write, it will process a small amount of data (say a few thousand points). Now, why would your assignment be to calculate the square of the distance: R2 = ∑(xi − xj)2?

Do you really mean: R = √∑(xi − xj)2?

emc

" The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents."
—Nathaniel S. Borenstein