in reply to Re: Memory /speed questions
in thread Memory /speed questions
Using large lists in a foreach, ie. foreach (1..10000) { }.
Whilst this used to be so, in recent versions of perl, (5.6.x/5.8.x) it is no longer so.
Neither for (1 .. 10_000_000) { ... }
nor for ( @a ) { ... }
will consume an (extra) memory as they are implemented as iterators. In the latter case, the control variable or $_ is aliased to the array element, so even if @a is huge, no additional memory is consumed by the construct.
|
|---|