John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
Ajey Kulkarni wrote:
Alright, but what is the reason for less time when you pass the
ref? I always thought the perl optimizes by sending the ref even
if you use a direct array.

When you pass an array, Perl *copies* the array elements to @_, so you get two instances of the data in memory.

perl stores an alias of each element passed to it into @_ just like foreach does so the *data* is only stored once.

Thanks for correcting me, John. I don't know what I was thinking of, really...

But since that's the case, and back to Ajey's question, is there really
any significant efficiency difference between passing an array compared
to passing an array reference?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to