Hi,
Pardon me if I should have posted this in my previous post, but I feel that this topic is a different discussion. Well, I have successfully pulling what I need from this data file and print them out onto a different file the order that I wanted.
[CODE=perl] $h_temps{$stn." ".$vol." ".$r1." ".$x1." ".$mag2} = $stn."\t".$vol. "\t".$r1." ".$x1." ".$mag2;
foreach my $z (sort keys %h_temps)
{
print OUTF2 $h_temps{$z}."\ n";
}[/CODE]
[CODE=text]T201 U1 0.00073 0.07142 -0.00258
T201 U1 0.00139 -0.00347 0.00000
T206 U1 0.00078 0.05879 -0.00356
T206 U1 0.00103 -0.00283 0.00000
T206 U2 0.00069 0.05408 -0.00235
T206 U2 0.00084 -0.00288 0.00000
T209 U1 0.00070 0.09190 -0.00093
T209 U1 0.00110 -0.02090 0.00000 [/CODE]
However, you can also tell that the name ($stn) in the record appears twice with different numbers ($r1,$x1,$mag2) . So what I am attempting to do now is to add those numbers together (in this case just two), which have the same name.
Desire:
[CODE=text]T201 U1 0.00869 0.06795 -0.00258
T206 U1 0.00883 0.05532 -0.00356
T206 U2 0.00153 0.05120 -0.00235
T209 U1 0.00180 0.07000 -0.00093 [/CODE]
Can you guys tell me how I should approach this. I tried putting $r1,$x1,$mag2 into an array and incrementing it, but when all I printed out is the index numbers.
[CODE=perl]@array[$i] = ($r1,$x1,$mag2) ;
}
$i++;[/CODE]
I am only testing it right now so I don't have a solid code to post up.
Thanks
Pardon me if I should have posted this in my previous post, but I feel that this topic is a different discussion. Well, I have successfully pulling what I need from this data file and print them out onto a different file the order that I wanted.
[CODE=perl] $h_temps{$stn." ".$vol." ".$r1." ".$x1." ".$mag2} = $stn."\t".$vol. "\t".$r1." ".$x1." ".$mag2;
foreach my $z (sort keys %h_temps)
{
print OUTF2 $h_temps{$z}."\ n";
}[/CODE]
[CODE=text]T201 U1 0.00073 0.07142 -0.00258
T201 U1 0.00139 -0.00347 0.00000
T206 U1 0.00078 0.05879 -0.00356
T206 U1 0.00103 -0.00283 0.00000
T206 U2 0.00069 0.05408 -0.00235
T206 U2 0.00084 -0.00288 0.00000
T209 U1 0.00070 0.09190 -0.00093
T209 U1 0.00110 -0.02090 0.00000 [/CODE]
However, you can also tell that the name ($stn) in the record appears twice with different numbers ($r1,$x1,$mag2) . So what I am attempting to do now is to add those numbers together (in this case just two), which have the same name.
Desire:
[CODE=text]T201 U1 0.00869 0.06795 -0.00258
T206 U1 0.00883 0.05532 -0.00356
T206 U2 0.00153 0.05120 -0.00235
T209 U1 0.00180 0.07000 -0.00093 [/CODE]
Can you guys tell me how I should approach this. I tried putting $r1,$x1,$mag2 into an array and incrementing it, but when all I printed out is the index numbers.
[CODE=perl]@array[$i] = ($r1,$x1,$mag2) ;
}
$i++;[/CODE]
I am only testing it right now so I don't have a solid code to post up.
Thanks
Comment