Solved

reference

Posted on 2000-05-17
5
160 Views
Last Modified: 2010-03-05
when should i pass by reference?
($r, @d) = DBQuery(\%dbinfo, $sql);

what is the advantage of it?
0
Comment
Question by:mwhuen
5 Comments
 
LVL 12

Expert Comment

by:geotiger
ID: 2817969
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
 
LVL 16

Accepted Solution

by:
maneshr earned 10 total points
ID: 2817975
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
 
LVL 84

Expert Comment

by:ozo
ID: 2819985
perldoc perlref
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2837273
did you get the answer you were looking for?

let us know.
0
 

Author Comment

by:mwhuen
ID: 2853955
Comment accepted as answer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question