Perl: the Markov chain saw | |
PerlMonks |
Re: Learning to *really* love referencesby vladb (Vicar) |
on Jul 30, 2002 at 02:26 UTC ( [id://186122]=note: print w/replies, xml ) | Need Help?? |
Well, I guess I had that in me from years spent coding C/C++, but alwasy pass references to data instead of replicating it. Undoubtfully this is a rather trivial skill to grasp and anyone who'd spent at least 6 month coding would *I hope* know that.
Perl is actually quite good when it comes to references. Certainly much easier to handle than C pointers for example. Take a look at this snippet: Perl is farily well optimized and in this for loop no memory gets duplicated. Instead, the s/// operator works on data stored in the original place (allocated for the a,b,c variables). There are numerous other examples one could bring up. Not the least is the ease with which you can pass references around in perl. In fact, I believe this is one of the first basic things that any novice Perl book would mention to its reader. For those who don't have a book however, I suggest refering to this excellent 'article' on Perl references here (written by fair brother dominus. _____________________
In Section
Meditations
|
|