On 04/03/2017 06:52 PM, SSC_perl wrote:
        Reading http://perldoc.perl.org/perlreftut.html I see it’s possible to 
create a scalar reference.  What situation would require someone to create a 
reference to a scalar?  I thought refs were only useful for passing complex 
data structures.  Is it just because Perl lets you, or is there a reason I’m 
not aware of?  It seems like it would just be redundant.



i have used them for efficiency when passing large strings or buffers. perl will copy a scalar onto the stack when passing into or back from a sub. passing a scalar ref is cheap (just a single SV with a pointer for its value in internals parlance). that is one use and there are others. not as common as using refs for arrays and hashes but it definitely can be useful for scalars.

uri

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to