open(IN, "/path/outModified.pl") or die "$!"; while (my $line = ) { chomp($line); my @array = (split (/\s+/, $line))[6, 7, 8]; # print "@array\n"; push @points, [ @array ]; } close(IN); print '@points : ', Dumper \@points; open my $out_file, '>', "/path/dist_modified.pl" or die "cannot open: $!\n"; for my $i1 ( 0 .. $#points -1 ){ my ( $x1, $y1, $z1 ) = @{ $points[$i1] }; for my $i2 ( 1 .. $#points){ my ( $x2, $y2, $z2 ) = @{ $points[$i2] }; my $dist = sqrt(($x2 - $x1)**2 + ($y2 - $y1)**2 + ($z2 - $z1)**2); print $out_file "153L.pdb: the distance between CA $i1 and CA $i2 = $dist\n"; } } close $out_file or die "cannot close file: $!\n";