Exercises, examples and other material relating to training module P304. This topic is presented on public course Perl for Larger Projects

Perl variables can be given nonstandard characteristics, such as persistence so that they won't be lost when you exit from a program and then start it again. There are a number of exciting things you can do with this facility, known as tieing, but you also need to be careful that the code you write is easy to understand and maintain too.

When variables behave differently - Tie in PerlDeep in the bowels of any programming language is code to store information into a variable, and get information back from that variable. And in a language that's dynamic in its memory allocation, there will also be code to construct and destroy variables.
Does that sound a bit "object oriented". ...

Setting up a matrix of data (2D array) for processing in your programWhen 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 ...

Changing a variable behaviour in Perl - tieingWhat can you do with a scalar variable? When you reduce it to lowest level programming principles, not a lot ... you can create it, destroy it, save a value into it, and read a value back from it. That's about it, when you think of it!
In Perl, the low level memory accessors within the language ...

Making variables persistant, pretending a database is a variable and other Perl tricksHave a look at this Perl program:
use fyle;
tie $counter,"fyle";
$counter = $counter + 1;
print ("This is access no. $counter\n");
Apart from the rather curious module loaded at the top, this seems to take an undefined variable, set it to one, and print it out. What a - err - pointless (!) ...

Tieing to scalars, hashes and lists.Tieing to a scalar.Tieing to a hash.Tieing to make data more permanent.Tieing a text file to a scalar.Tieing a text file to a hash.Tieing to database files.Accessing system databases.Tieing lists.Tieing File Handles.

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.