in reply to Re^3: why i cant print reading hash table?
in thread why i cant print reading hash table?
Nice that you++ picked up the off by one which exactly illustrates the problem with C for loops. I don't much like the while loop solutions because they don't make the number of iterations clear, particularly in conjunction with the post decrement operator - that's just far too subtle.
Actually, to get the count right and clear I'd:
for (1 .. $count + 1) {
If the values are required I'd:
for my $value (reverse 0 .. $count) {
which makes it very clear that the values are required in reverse order and the span of values required, but obfuscates the number of iterations somewhat.
|
|---|