A
Andrea Spitaleri
Hi I have few quick question about array:
1. reading a file as array, that below code works but I want be sure
that it is correct that portion
I am in doubt about the $numb[$countmol].
open (IN,"in") || die "$!";
@in=<IN>;
clode IN;
my $i;
for ($i=0;$i<$#in;++$i){
chomp $i;
my $countmol=0;
if($in[$i]=~ /^@<TRIPOS>ATOM/){
$initial=$i;
$endmol=$number_atoms + $i;
for($k=$initial;$k<$endmol;++$k){
@coord=split(/ +/,$inmol[$k+1]);
#that is it correct?? $numb[$countmol] is different from $numb[$i].
$numb[$countmol]=$coord[1];
$atom[$countmol]=$coord[2];
$x[$countmol]=$coord[3];
$y[$countmol]=$coord[4];
$z[$countmol]=$coord[5];
$atype[$countmol]=$coord[6];
$atype[$countmol]=$coord[6];
$charge[$countmol]=$coord[9];
++$countmol;
}
}
}
2. If I want create an output like that:
1 2 3
4 5 6
7 8 9
.........
how is the code?
thanks a lot
cheers
and
1. reading a file as array, that below code works but I want be sure
that it is correct that portion
I am in doubt about the $numb[$countmol].
open (IN,"in") || die "$!";
@in=<IN>;
clode IN;
my $i;
for ($i=0;$i<$#in;++$i){
chomp $i;
my $countmol=0;
if($in[$i]=~ /^@<TRIPOS>ATOM/){
$initial=$i;
$endmol=$number_atoms + $i;
for($k=$initial;$k<$endmol;++$k){
@coord=split(/ +/,$inmol[$k+1]);
#that is it correct?? $numb[$countmol] is different from $numb[$i].
$numb[$countmol]=$coord[1];
$atom[$countmol]=$coord[2];
$x[$countmol]=$coord[3];
$y[$countmol]=$coord[4];
$z[$countmol]=$coord[5];
$atype[$countmol]=$coord[6];
$atype[$countmol]=$coord[6];
$charge[$countmol]=$coord[9];
++$countmol;
}
}
}
2. If I want create an output like that:
1 2 3
4 5 6
7 8 9
.........
how is the code?
thanks a lot
cheers
and