|
Hi,
I have a file with four rows, 2 columns
1 2 1 2
3 4 5 6
7 6 4 6
1 1 1 1
Output the sum of columns
My code is:
for (i=0; i<4; i++){
while<INPUT>{
$line=$_;
chop($line);
@bps=split(/\t/,$line);
sum[$i] += $bps[$i];
}
}
Anybody can tell me
What's wrong with this code? :(
|
|
|
first of all its not commented.
secondly it mixes multiple actions, like, reading the information into array and processing the information.
thirdly there's no tabbing, tabbing is very important to maintain readability.
'I have a file with four rows, 2 columns'
this looks like four rows and four columns to me.
the input filehandle isn't defined before it is applied.
|
|
|
Thank you very much for your words. You are absolutely right.
I realized that my code is poorly maintained.
I will work harder.
Thank you again.
|
|
|
|
|
|
|
// |