Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Seeing Perl in a new light

by CountZero (Bishop)
on Apr 12, 2009 at 17:33 UTC ( #757111=note: print w/ replies, xml ) Need Help??


in reply to Seeing Perl in a new light

Lady Aleena,

"'t Is costly wisdom that is bought by experience" as Roger Ascham, Scholemaster said.

Now for your project, it looks to me that the major part of your web-site is entirely static in nature, but that from time to time you add files and links and ... which must be reflected in the various pages you have on your site.

One solution would be to have the structure of the web-site "rendered" on the fly for every hit, but that seems wasteful of resources since the majority of the info did not change at all and once the changes have been rendered they should not be re-rendered when next this page is accessed.

Another --IMHO preferable-- solution is to use a templating system, such as Template::Toolkit to rebuild your site every time you change something. it has a lot of functionality already build in to add headers and footers. The pages are mostly pure HTML with the variable bits and pieces either written in the Template::Toolkit language (which is very close to Perl) or even directly in Perl itself.

In the docs of Template::Toolkit we read:

A number of special directives are provided, such as INSERT, INCLUDE and PROCESS, which allow content to be built up from smaller template components. This permits a modular approach to building a web site or other content repository, promoting reusability, cross-site consistency, ease of construction and subsequent maintenance. Common elements such as headers, footers, menu bars, tables, and so on, can be created as separate template files which can then be processed into other documents as required. All defined variables are inherited by these templates along with any additional "local" values specified.

Just like you and Perl, it took me a while to discover the beauty and usefulness of this templating system, but now I use it regularly (and not only to make web-sites). Check it out, it could empower your new understanding of Perl even more!

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James


Comment on Re: Seeing Perl in a new light
Re^2: Seeing Perl in a new light
by Lady_Aleena (Deacon) on Apr 13, 2009 at 06:58 UTC

    CountZero...What you are discussing is the navigation section of the pages which I would like to have created with each hit, I think. I am open to be swayed to having a semi-static list somewhere of every page and directory on my site. I would prefer to have the navigation be where I get it written, test that it works, once it does, make it live, then forget it is there.

    I gave Template::Toolkit a quick skim and am unsure how it can help me. I would like to build as much of this from scratch before I start looking into modules. In my neophyte opinion, the module is more confusing at the moment. I have just wrapped my head around subs, but that module as a whole confuses me.

    What I am hopefully building is a shell for all of the pages on my site, a template if you will. It seems funny to me to use a template to build a template. :)

    I wish I understood how to make this a module, but even that is out of reach for now. Instead of useing it, I will be doing it instead. I know I should be looking at the former, but the module mojo makes no sense to me.

    Have a nice day!
    Lady Aleena
      Just go as fast as you are comfortable with now, but remember there will be new horizons and perspectives around each corner and be prepared to be flexible and drop any "fixed" knowledge when something better comes along.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://757111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-12-18 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (47 votes), past polls