File: mylib.pl #This file defines two subroutines. sub My_Load_Func { ($file_to_load, $ID)=@_; #ID is the page id in a database, used by some of the embedded routines. # If I could set ID as a variable in the mylib.pl object, I could use # this slot in the templates to pass the object, but I haven't figured out how #Function calls My_Define_Vars, passing it the $ID, then #Function now loads $file_to_load via Text::Template, # placing a "require /path/to/mylib.pl" in the PREPEND section # (Text::Template allows you to embed perl code, # but each embedded block is in a new namespace. # Text::Template also passes in the Vars defined in My_Define_Vars } sub My_Define_Vars { #This function sets several variables, #Some are static (such as RootPath, which is prepended to any paths) #some are looked up in a database based on the passed ID. #Under the current system, I have several variants of mylib.pl, #Each with different variations on these variables. #This lets me use the same content pages (below) with different templates and variables #to generate different pages (for example, test site vs live site, text site vs graphical, etc) } file: Content.html # This is a sample content file. #I have several hundred of these, and don't have sole control over them # so any redesign of the system shouldn't modify how these look #Text::Template is set to look for tags wrapper for editing !!> HTML content here file: Template #there are many templates. Each template can # call other templates through cascading &My_Load_Func calls. # Eventually results in HTML. file: Calling script #There are several calling scripts, each with a different purpose #THese scripts are little more than: #--Determining which file and ID to pass to an initial call to My_Load_Func, #--which mylib.pl to use, #--what to do with the results.