($endstore[$ctrend][0], $endstore[$ctrend][1], $endstore[$ctrend][2], $endstore[$ctrend][3], $endstore[$ctrend][4]) = @arr;
can be abbrieviated to
@{$endstore[$ctrend]}[0..3] = @arr[0..3];
If I read the intent correctly, it can be abbrieviated further to
$endstore[$ctrend] = [ @arr ];
Of course, since $ctrend is always being incremented, we simply want
push @endstore, [ @arr ];
Final result:
while (my @arr = $sth2->fetchrow_array() ) { push @endstore, [ @arr ]; my ($field1, $field2, $field3, $field4, $field5) = @arr; $endflag=2; print STDOUT "Field 1: $field1 Field 2: $field2 " . "Field 3: $field3 Field 4: $field4 " . "Field 5: $field5\n"; }
Note that [ @arr ] can't be replaced by \@arr since you'd be pushing multiple references to the same array.
In reply to Re^2: Extra iteration while fetching 'fetchrow_array' in DBI and standerd way of using DBI
by ikegami
in thread Extra iteration while fetching 'fetchrow_array' in DBI and standerd way of using DBI
by cool
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |