Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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


In reply to Re: Seeing Perl in a new light by CountZero
in thread Seeing Perl in a new light by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-24 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found