reference

when should i pass by reference?
($r, @d) = DBQuery(\%dbinfo, $sql);

what is the advantage of it?
mwhuenAsked:
Who is Participating?
 
maneshrConnect With a Mentor Commented:
foll is a general explanation of when references are very useful.

A Perl reference is a fundamental data type that "points" to another piece of data or code. A reference knows the location of
the information and what type of data is stored there.

A reference is a scalar and can be used anywhere a scalar can be used.

References are absolutely essential for creating complex data structures.

When you pass more than one array or hash to a subroutine, Perl merges all of them into the @_ array available within the
subroutine. The only way to avoid this merger is to pass references to the input arrays or hashes.
0
 
geotigerCommented:
Passing a reference is just passing a point, not the whole array or object. It is quicker, cheaper (using less memory), and safer (you do not need to keep two or more copies of the same data).
0
 
ozoCommented:
perldoc perlref
0
 
maneshrCommented:
did you get the answer you were looking for?

let us know.
0
 
mwhuenAuthor Commented:
Comment accepted as answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.