[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-beginners
Subject:    Re: ref() or ! ref()
From:       Telemachus <telemachus () arpinum ! org>
Date:       2009-06-23 18:47:16
Message-ID: 20090623184716.GA7919 () ithaka
[Download RAW message or body]

On Mon Jun 22 2009 @ 11:10, Steve Bertrand wrote:
> I've got a relatively decent understanding of how references work in
> Perl (syntax-wise, especially when/how to de-ref), but I'd now like to
> ask when to use them.
> 
> Obviously memory allocation isn't an issue anymore, so when exactly
> should refs be used, and in what circumstances shouldn't they be used?

I'm not quite sure what you mean by "memory allocation isn't an issue
anymore." Do you mean "With modern hardware, who cares about memory
saving?" If so, I don't know that I would go that far. Premature
optimization may be evil, but copying huge arrays and hashes just for fun
seems silly, too. So, I do use references when passing arrays or hashes
to functions or returning them from functions.

More generally, references are essential for complex data structures. My
favorite brief introduction to references comes at them from that angle:

perldoc perlreftut

You might also take a look at two other tutorials in perldoc:

perldoc perllol
perldoc perldsc

Enjoy, T

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic