On Wed, 28 Apr 2010 01:16:16 -0400, Uri Guttman wrote: >>>>>> "PS" == Peter Scott <pe...@psdt.com> writes: > > PS> On Mon, 26 Apr 2010 22:16:27 +0800, Tim Bowden wrote: > >> I've just realised I almost never use named arrays or hashes > >> anymore. It's almost always anonymous references instead. That > >> lead me to wonder what criteria experienced perl hackers have as to > >> when to use a named array or hash, and when to start with an > >> anonymous ref instead. My very informal criteria tends to be to > >> use an anonymous ref from the start if I'm going to be passing it > >> to a sub, and a named array or hash otherwise. I've found the > >> former to be much more common. Thoughts? > > PS> I create arrays and hashes by default, not references to anonymous > PS> versions. I'd sooner not be putting arrows in unnecessarily. I > can PS> always enreference an aggregate in the call to a sub. > > my choice is usually based on usage. if i am building up data > structures, the members are almost always anon refs - no need to have > named vars for them.
Right. I should have said that I don't create named references, most of the time, but anon references as part of a data structure, sure. In other words, I very rarely do my $some_ref = \anything or [anything] or {anything} as in the original post. -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ http://www.informit.com/store/product.aspx?isbn=0137001274 http://www.oreillyschool.com/courses/perl1/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/