http://www.perlmonks.org?node_id=1010354

ISAI student has asked for the wisdom of the Perl Monks concerning the following question:

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

The Two packs of code do the same action. Should there be any perforance gap (memory and/or execution time) chunk 1:

my @lines=foo('bar'); foreach my $line (@lines) { $a.=chomp $line ; $b*= getVa($line);# a parsing function }
chunk 2:
foreach my $line ( foo('bar') ) { $a.=chomp $line ; $b*= getVa($line);#a parsing function }
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