in reply to Code Critique?

One thing that I would consider doing is avoid mixing here-docs with the CGI.pm HTML output functions; you should try to use one or the other, and IMO, the CGI.pm HTML is a better approach, since you avoid known problems with formatting the code correctly for here-docs. While my first thought is that you'd have to still code the APPLET portion of the HTML code in a here-doc, I think that if you use some of the special features of CGI.pm that can generate HTML tags that it doesn't specifically support, you can have every bit of HTML be done via CGI.pm rather than here-doc.

If anything, if you have a static bit of text, which your applet code is, I've found that using q() and friends are better than here-doc-ing those.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Replies are listed 'Best First'.
Re: Re: Code Critique?
by sierrathedog04 (Hermit) on Jun 15, 2001 at 20:13 UTC
    Why do you say that one should avoid mixing CGI.pm's HTML functions with here documents?

    I often do something similar to the following:

    use strict; use CGI; #tested on 5.005/UNIX my $q = new CGI; print $q->header(), $q->start_html(-title=>'CDB Form'); print <<END_of_Multiline_Text; HTML text here END_of_Multiline_Text print $q->end_html();
    This enables me to reuse existing HTML code, and I do not have to remember the correct http headers to post. Moreover, I can even interpolate Perl variables in my here document if I want to.
      Well, it's not that this doesn't work. As with most of perl, TIMTOWTDI. But I was more advocating mixing here-docs with CGI's functions, (as opposed to mixing CGI.pm with here-docs)

      I've lately becoming less enthralled with here-docs due to how they ususally mess up the formating (both of what you put in and what your editor puts in) of a perl script. Plus, this appears to be one of the few points in perl where extra whitespace can screw you up. I've had several bad experiences with here-docs as to avoid using them myself and to try to get others to do so as well.

      It's probably better to use either CGI.pm functions completely, or at least get the header and other page information out with CGI and then jump to a template solution for the rest of the HTML body. Both methods will produce much nicer and easier-to-read code than using here-docs.


      Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
        We are basically on the same (web) page. A lot of us have legacy HTML pages that we are integrating into new projects, and it is better to reuse them than to redo them as templates or using CGI.pm's HTML functions.

        I prefer to include the legacy HTML pages as here documents rather than as separate files. That way everything is one one file. In my office we are still working the kinks out of our version control system and anything that avoids adding to the number of files in a project is a plus.