perlquestion
ISAI student
<p>I am asking this performance and memory footprint-wise.
While I can experiment on my own, I'd rather have an analytical answer rather than empiric<p>
The Two packs of code do the same action. Should there be any perforance gap (memory and/or execution time)
chunk 1:
<code>
my @lines=foo('bar');
foreach my $line (@lines) {
$a.=chomp $line ;
$b*= getVa($line);# a parsing function
}
</code>
chunk 2:
<code>
foreach my $line ( foo('bar') ) {
$a.=chomp $line ;
$b*= getVa($line);#a parsing function
}
</code>
Assume that @lines is not used anywhere else in the scope of code.
I would assume that memory footprintwise, 2nd chunk should be no larger than chunk 1, unless the garbage collection does not work in the wasy I expect it to.
I am not sure how should the performance scale.
Thanks
</p>