Much of the work you're trying to avoid is done anyway when the braces define a scope. Generally, the idea is to use scoping to get rid of knowledge where it's unneeded. I'd use the second form in question one because $foo is then undefined afterwards. Similarly for question two, get rid of the declaration outside the loop.
If you must, you can make the exterior declaration and then say ($key, $value) = returnsAnArray(); inside the loop. I think the loops would be better written as { my $i = 0; while ($i++ < $a_big_number) { ... }} rather than the C-style for loops you have. You could also say for (0..$a_big_number) { ... }, but that is no way to save memory.
After Compline,
Zaxo
In reply to Re: Two Questions on "my"
by Zaxo
in thread Two Questions on "my"
by C_T
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |