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.