Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Perl module P217
More than Simple Lists and Hashes!
Exercises, examples and other material relating to training module P217. This topic is presented on public courses Perl Programming, Perl for Larger Projects, Perl bootcamp, Learning to program in Perl, Perl Programming

As well as lists and hashes, Perl has the capability of handling collections of data in more complex structures; you're limited only by your ingenuity! A study of these more complex structures is vital if you're to understand how Object Orientation works in Perl, and the subject is equally essential if you're going to be doing serious data munging without using objects.


Articles and tips on this subjectupdated
3444Take the dog on a lead - do not carry her. Perl references.
Taking the dog out for a walk? It's much easier to use a lead than to carry the whole dog. And ... in a similar vein ... when you're passing some data into a named block of code (a.k.a. sub, subroutine, function, procedure, command, method, macro) when programming, it's much more efficient to pass ...
2013-01-01
 
3906Taking the lead, not the dog, for a walk.
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" ...
2012-11-03
 
3577How to do multidimensional arrays (or rather lists and hashes) in Perl
In Perl, you can have a list of lists, a hash of hashes, a hash of lists or a list of hashes - in effect, two dimensional arrays but with much more flexibility.And where you can have two dimensional arrays, you can go further and have 3, 4, or more dimensions - you are limited only by your ingenuity. With ...
2012-01-28
 
3406Not multidimentional arrays - but lists of lists. Much more flexible. Perl!
In Perl, you don't have multidimensional structures as such - you have list and hashes ... and you can have lists of hashes, hashes of lists and hashed of hases too. Which give you almost all of the benefits of multi dimensional structures, but with few of the limitations. And they can be set up in ...
2011-08-26
 
3399From fish, loaves and apples to money, plastic cards and BACS (Perl references explained)
Money's useful stuff. Before money, transactions were undertake on a barter system; if I wanted a loaf of bread I might exchange it for a fish. If I was wanting to book passage on tthe stagecoach from the George in Melksham to London, I would have to take ia bushel of apples into my local travel agent, ...
2011-08-20
 
3105Adventure with references to lists and lists of references
I remember an old game I used to play on DEC 10 (and VAX and PDP-11) computers - the original adventure game, perhaps ([see here]) which was pure text / instruction based and you traveled North, South, East and West through the colossal cave. And there was one are - the maze - where you could get rather ...
2011-01-03
 
3118Arrays of arrays - or 2D arrays. How to program tables.
It's shorthand when you're learning a new programming language to ask "how does it handle multiple dimension arrays" ... but in practise very few languages actually support true multidimensional arrays these days, and in those which do you might be well advised to use an alternative that's more flexible. What ...
2011-01-03
 
3072Finding elements common to many lists / arrays
"What do these lists have in common". That's a common question - but what does the person asking it actually mean? Is (s)he looking for items that occur in all of the lists, but perhaps at different positions? For items that occur in two or more of the lists? For items that occur at the same position ...
2010-11-27
 
2996Copying - duplicating data, or just adding a name? Perl and Python compared
When you copy a list in Perl, you're duplicating the data and you end up with two distinct copies ... but when you copy a list in Python, you're copying the reference so that you end up with two names for the same variable - almost like an alias. So in Perl - with two different copies - you end up with ...
2010-10-30
 
3007Setting up a matrix of data (2D array) for processing in your program
When you're reading and processing data, it often comes in the form of a series of records, with each record being split into a series of fields, and you'll often want to be going through the data several times, looking at different rows and colums, sorting them, comparing them, and so on. If the amount ...
2010-10-21
 
2877Further more advanced Perl examples
I've uploaded a further batch of new examples (that makes around 40 in total!) from the private Perl course that I ran from Wednesday through Saturday last week - many of them adding a new twist on to previous examples. If you read a comment below and thing "that's what I'm looking for an example of", ...
2010-07-30
(longer)
2840Just pass a pointer - do not duplicate the data
When you want to pass a big bundle of data - such as an array - into a function, it's far more efficient to pass in just a single value in the form of a pointer to the array. That's the address in memory at which the array starts and that single value can provide the key to all the data without havig ...
2010-06-30
 
2241Perl references - $$var and \$var notations
In Perl, if I write: $stuff = "Porridge"; then I'm setting up a variable to contain the value "Porridge". If I write: $stuffat = \$stuff; then I'm setting up a variable to contain the ADDRESS OF the variable $stuff. So if $stuff was in memory at (hex)fe80 ... then $stuffat will be assigned that value ...
2009-06-22
 
1514Autovivification - the magic appearance of variables in Perl
Here's a one line perl program that does nothing but set up a variable ... except that it does a lot! $p[7]{john}{paul}[9] = 1;   __END__   A list called @p. Elements 0 to 6 are null, and element 7 is a reference to a hash ...   That hash contains a single member, key is "john" and the ...
2008-01-21
 
43Hash of lists in Perl
Here's a short program that reads data into a hash of lists, sorts the keys and displays output data - a simple Perl program showing powerful capabilities of the language. while () { my ($name,@temporary) = split; $want{$name} = \@temporary; } foreach $person (sort keys %want) ...
2006-06-05
 
Examples from our training material
2ds   Setting up a list of lists (like a 2D array)
2tiny   A list of lists - autovivification
ar2   Combining lists - list of lists v one long list
ar3   Rekeying data
ar3.cgi   Rekeying data / presenting it on a web page
ar4   Reading a data file into a structure
clutter   Finding items common to a number of liats
d2   Passing list, passing reference to list comparison
d3   Collection of collections (i.e. 2D array)
deal   A list of lists - dealing a pack of cards
deal2   List of lists - flexible example
haha   A hash of hashes
hali   Example of a hash of lists
hohum   hash of list of hashes
lili   lists of lists - like a multidimensional array
lili2   List of lists
lilo   Collections and references to collections
m2   Passing a reference to a hash
menu   Passing a reference to a list
multikey   A Hash of lists - a more complex example
rain   Setting up a hash of lists
ref2   References - the fundamentals
refs   References - a first demo
revise   Revision of reference notations in Perl
rn2   Pushing a list v pushing a reference to a list
rq2d   Setting up a hash of lists
rrr   Setting up a list of lists (like a 2D array) from a file
show_acc   Setting up a list of lists
slush   Setting up a list of lists in Perl
Pictures
Two students on a public Perl course in Melksham
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
Multidimensional arrays.
Multidimensional lists.
Mixing the dimensions.
Something more complex.
Design first.
Setting up the structure.
Referencing the structure.
Grouping in Perl.
Interpreting a complex reference to a variable.
Design MATTERS.
Summary.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre.


You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.info/resources/P217.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb