http://www.perlmonks.org?node_id=76182

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

I've happily got the basics of mod-perl, DBI, and CGI.pm down...

Now I'd like to make some nice looking webpages, not just the uglies that I am currently auto-generating with CGI.pm.

How can I do this? CGI.pm allows me to do so much programatically: populate pop-up boxes based on database lookups, decide whether or not to print certain elements of the page based on database lookups...

Can I still do these wonderful things and yet have it come out slick looking? Thanks for any advice!

Phil R Lawrence

Replies are listed 'Best First'.
Re: CGI.pm - Dreamweaver or somesuch?
by Masem (Monsignor) on Apr 27, 2001 at 21:41 UTC
    As we've talked about recently (such as here), you want to try separate perl code from HTML as much as possible, and the various templating solutions that exist (HTML::Mason, HTML::Template, or Template, to name a few) help you do this.

    The key is to collect all the data that you need in the perl part of the program, and then throw that to the template file. Once you have the perl logic down, it's very easy to play whatever pretty-ing games you need to do with the HTML to make the output look good. You just simply need to embed the data from perl into the appropriate places.

    This approach makes the job of programming web sites for both function and appearence very simple.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
(jeffa) Re: CGI.pm - Dreamweaver or somesuch?
by jeffa (Bishop) on Apr 27, 2001 at 21:39 UTC
    How about a templating system? I wrote a tutorial on HTML::Template here.

    There is also Template-Toolkit which is more powerful, and consequently more complex.

    Jeff

    R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
    L-L--L-L--L-L--L-L--L-L--L-L--L-L--
    
    http://search.cpan.org/search?dist=Template-Toolkit
Re: CGI.pm - Dreamweaver or somesuch?
by rchiav (Deacon) on Apr 27, 2001 at 21:45 UTC
    Anything you can do with a WYSIWYG HTML editor like "Dreamweaver" or other bulky programs, you can do with a text editor. The only diffeence is that you have to know what you're doing when you do it by hand. All Dreamweaver does is generate the HTML for you. There's nothing special about the files that it generates, well except for the fact that they are much bigger than they should be because it inserts a lot of HTML that isn't needed.

    If you're willing, I'd highly recomend learning how to write the HTML yourself. Take a look at W3C's Tutorials for starters. There's also a good refrence here from Microsoft. Then you can take that knowledge and use CGI.pm to create what you want. It's not CGI.pm's fault that the pages don't come out the way that you want. It's just generating the HTML that you're telling it to.

    Hope this helps..
    Rich

Re: CGI.pm - Dreamweaver or somesuch?
by tphyahoo (Vicar) on Feb 23, 2005 at 13:09 UTC