Main Content

Taking the lead, not the dog, for a walk.

Archive - Originally posted on "The Horse's Mouth" - 2012-10-28 09:05:16 - Graham Ellis

When I say that "I'm taking the dogs for a walk", I don't literally carry the dogs for a walk - they walk themselves and I just hold the leads.

Statement of the obvious? Yes!

But you would be surprised how many programmers pass complete full data structures into named blocks of code - "subroutines" - rather than just passing the address / a refernce to the data structure which is rather like the dog's lead. Th etemptation to pass data in this inefficient way is particularly stong in Perl where
  domysub(@info);
passes a complete second copy of the data in the list in @info to the sub, whereas
  domysub(\@info);
would simply pass in a reference - lightweight, like the dog leads - even though the dogs shadowed here weigh 31kgs and 36kgs.

Our Perl Courses go into this subject in a much more through way - not only do we teach you Perl, but we teach you to write good Perl. Next course - 6 weeks time ... places still available!