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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|