ganeshPerlStarter has asked for the wisdom of the Perl Monks concerning the following question:
Dear Perl Monk friends,
I am primarily a C++ programmer and now learning perl.
This question is to know difference between pass by value vs reference to function in perl and C++.
C++ recommends pass-by-reference to avoid object copying overhead, since pass-by-value involves copy of the object being passed to function.
Also, when we return an object (return-by-value) from a C++ function, it involves a temp object creation & destruction.
perl also allows pass-by-reference to functions. Also, we can return values or references from perl functions.
In this context, does pass-by-reference and return-by-reference help to avoid object copying overhead in perl also?
I am trying to optimize my perl script so that when there are many functions, I want to reduce/eliminate the overhead of object copying while passing them to and returning from functions. I've a perl script which parses lot of data from web & it takes too long to process the data. That's why I am looking at these aspects in my script.
Many thanks for clarifying my query.
Best Regards
ganesh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: pass by value vs reference and return by value
by hippo (Bishop) on Oct 27, 2013 at 14:08 UTC | |
Re: pass by value vs reference and return by value
by Athanasius (Archbishop) on Oct 27, 2013 at 14:57 UTC | |
Re: pass by value vs reference and return by value (terms)
by tye (Sage) on Oct 27, 2013 at 16:46 UTC | |
Re: pass by value vs reference and return by value
by ww (Archbishop) on Oct 27, 2013 at 16:07 UTC | |
Re: pass by value vs reference and return by value
by Laurent_R (Canon) on Oct 27, 2013 at 17:16 UTC |
Back to
Seekers of Perl Wisdom