For each event, you can fill in an anoymous routine to manipulate the text. In the template we need to add in a line which calls the references module.
Different events can have very different subroutines.
Some may just trigger flags, others may produce output. Output is handles using an output stack, more of which later. The subroutines are event based, that is to say, they are triggered by certain things occuring. In the template,a hash table is created. Information that we do not wish to output immediatly, or other types of information are stored in this hash table.