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!
Some other articles
Z203 - Cat and Dog Spring at Well House Manor Day trip to Lancaster Black dog day - and Bobby still seeks his new home In favour of adoption rather than puppy purchase - dogs! Different views of a Welsh Valley - but headed home Crisp morning, fast run Misty Melksham Morning Too many Staffies, too many lurchers Who are we - Lisa, Graham, Gypsy and Billy Exceptionally, I sign a petition - on a life and death issue for Irish dogs Soft furnishings up a Welsh Mountain Red, yellow, green or pink dog? Yellow Dog Project With us for a year already! Lisa is home today ... Challenge for a photographer Black dogs at Halloween This article Postcards from Barmouth Spring 2012 Off to walk the dogs An update on Billy the Greyhound and Gypsy the Lurcher Gypsy and Billy enjoy the snow Happy Christmas ... a Christmas morning walk in Melksham Changes to morning routines I loves Melksham Letting the foster parents know ... too little or too much? No message - just doggy pictures of the new doggy A typical weekend?? Return trip - Dogs Trust, Newbury Rabbit Shelter Contrast in pictures The Land of the Black Labrador Sleeping in on Sunday Can my dog eat potatoes? Doggie Dietary Research, and political sleaze! Bookkeeping ourdog is Greyhound, Staffie and Ginger Cake A better design of mouth Bright Eyes Gypsy says Family Gathering at 404, The Spa The dog is not in trouble Dogs Trust, Dog Show, Newbury Leaping dog, Leaping horse, copyright of old masters Watching the tele Beware - giving copyright away when you upload a picture - Dogs Trust Ski bore ... train bore ... dog bore Learning about Lurchers Also for the eyes of the cat From cat breeder to Cobol to Perl We can offer a room, but we can't operate on a dog Taking the dog for a walk Variable Scope Technical Open House P217 - More than Simple Lists and Hashes! This article How to do multidimensional arrays (or rather lists and hashes) in Perl Take the dog on a lead - do not carry her. Perl references. Not multidimentional arrays - but lists of lists. Much more flexible. Perl! From fish, loaves and apples to money, plastic cards and BACS (Perl references explained) Arrays of arrays - or 2D arrays. How to program tables. Adventure with references to lists and lists of references Finding elements common to many lists / arrays Setting up a matrix of data (2D array) for processing in your program Copying - duplicating data, or just adding a name? Perl and Python compared Further more advanced Perl examples Just pass a pointer - do not duplicate the data Perl references - $$var and $var notations Autovivification - the magic appearance of variables in Perl Course follow-ups Hash of lists in Perl P208 - Lists in Perl Mapping an array / list without a loop - how to do it in Perl 6 Lots of ways of doing the same thing in Perl - list iteration This article Writing more maintainable Perl - naming fields from your data records Stepping through a list (or an array) in reverse order Dark mornings, dog update, and Python and Lua courses before Christmas $ is atomic and % and @ are molecular - Perl Copying - duplicating data, or just adding a name? Perl and Python compared Fresh Perl Teaching Examples - part 2 of 3 Iterating over a Perl list and changing all items Finding text and what surrounds it - contextual grep The dog is not in trouble Revision / Summary of lists - Perl Perl - lists do so much more than arrays Perl Socket Programming Examples Out of memory during array extend - Perl Perl - map to process every member of a list (array) Perl ... adding to a list - end, middle, start Filtering and altering Perl lists with grep and map Last elements in a Perl or Python list Perl - a list or a hash? C++ and Perl - why did they do it THAT way? Breaking bread Huge data files - what happened earlier? Queues and barrel rolls in Perl The fencepost problem Splitting the difference Context in Perl Conventional restraints removed Course sizes - beware of marketing statistics Comparison Chart for Perl programmers - list functions Perl for breakfast