in reply to Re: Trouble getting size of list returned from sub
in thread Trouble getting size of list returned from sub
Actually they all do that, they copy the list to the "stack", its just that map introduces a scope, by the time it ends, perl has a chance to release the memory it used back to the OS -- an optimization
For a long time map/grep in scalar/void context took double the memory than equivalent for loop, so depending on perl version memory usage will differ between these two lines
warn scalar grep {1} foo(); my $count = 0; $count++ for foo(); warn $count ;
wantarray is what you want to use if you want to be sure :)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Trouble getting size of list returned from sub
by ColonelPanic (Friar) on Nov 26, 2012 at 12:25 UTC | |
by Anonymous Monk on Nov 26, 2012 at 15:24 UTC | |
by ColonelPanic (Friar) on Nov 26, 2012 at 15:40 UTC |
In Section
Seekers of Perl Wisdom