Hi, I am trying to sum up all the second element in an array (@hello). I tried as below but cant work. Suppose i could get 12 ( 3+ 4 + 5)
please guide. thx
[CODE=perl]my @hello =();
push (@hello, join(",", 'A', 3));
push (@hello, join(",", 'B', 4));
push (@hello, join(",", 'C', 5));
$helo=(@hello);
for($y=0;$y<$he lo;$y++) {
push(@out, pop(@hello[$y]));
}
my $total = 0;
$total_in_array += $_ foreach @out ;[/CODE]
please guide. thx
[CODE=perl]my @hello =();
push (@hello, join(",", 'A', 3));
push (@hello, join(",", 'B', 4));
push (@hello, join(",", 'C', 5));
$helo=(@hello);
for($y=0;$y<$he lo;$y++) {
push(@out, pop(@hello[$y]));
}
my $total = 0;
$total_in_array += $_ foreach @out ;[/CODE]
Comment