Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

HTML dumping inside Perl script?

by Anonymous Monk
on Jan 04, 2003 at 01:51 UTC ( [id://224171]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hiya Guys! Hope everyone is doign well. I had a quick question and am quite sure that the answer is pretty simple, but its just not coming to me right now -- I have a perl script which dumps out a bunch of HTML code. Now the thing is that a have a few functions which require the same code to be dumped and would like a way where I can just refer to a HTML file or a library-type of file which contains all this HTML code. Is something like this possible? Also, can this library-file have "$" signs so that when the perl code dishes it out, the "$" values are converted into values as per assigned by the script? Please do let me know if I'm not making any sense and I will try to explain it in more detail. Thanks in advance. SP

Replies are listed 'Best First'.
Re: HTML dumping inside Perl script?
by tstock (Curate) on Jan 04, 2003 at 02:16 UTC
    You probably want to look at Template Toolkit or HTML::Template

    Look here 156860 , 75645 or just search for template in the search box above.

    Tiago
      I'd also refer to this article (props: perrin) to decide which templating system is best for you.

      --
      "I don't intend for this to take on a political tone. I'm just here for the drugs." --Nancy Reagan
Re: HTML dumping inside Perl script?
by tachyon (Chancellor) on Jan 04, 2003 at 09:27 UTC
Re: HTML dumping inside Perl script?
by Ionizor (Pilgrim) on Jan 04, 2003 at 15:22 UTC

    As the others have said, I would suggest HTML::Template. One of the things you don't want to run into is letting your script and template bleed together. I've seen CGI Perl tutorials that define variables inside their templates - occasionally a variable would just appear in the script out of nowhere. Once I determined that it didn't appear anywhere else in the script I then had to sift through the templates until I found where the variable was defined. When the author has created one template file per script state (which makes me wonder why he bothered with templates at all), that can take a while.

    HTML::Template doesn't really allow this sort of a maintainability nightmare to happen.

    --
    Oh Lord, grant me the wisdom to shut my mouth when I don't know what I'm talking about.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://224171]
Approved by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found