I am writing code for a new client who has some "interesting" code. I am worried I will say too much and jeopardize my position there, so I will be as vague as I can be.

None of the code uses -T, -Mstrict, or -w. Furthermore, most of it is written in a manner like this:

print <<'HTML"; <html> <head><title>Email This Article to a Friend</title></head> <center> <b>The following fields are missing or inproperly filled </b> + </center> <p> <hr> error_fields <p> <hr> <p> Please use the <b>back</b> button on your browser to return and comple +te the form. </body> <html> HTML
instead of
sub error_mf_page { print header, start_html( "Email This Article to a Friend" ), p( {-align => 'center'}, b( "The following fields are missing or improperly filled" +) ), p(), hr(), "@error_fields", p(), hr(), p(), "Please use the", b( " back " ), "button on your browser to return and complete the form.", end_html; }
The scripts (around 200 or so) are littered with HTML, and filehandles that point to html files in various directories (with special variable names and the like which are s///'d in at compile time).

This code is so unmaintainable it makes me ill to work in it. I was originally brought in to write some new programs, and add some functionality, as well as diagnose and test some problems they were having. The deeper you look, the more problems you see. You cant just go in and actually write new code, because it takes you four hours to figure out what the current code is actually doing.

So my question for the monastery then is, is there actually any advantage to writing code like this? To embedding html into perl scripts rather than using it the way its supposed to be (i.e., perl is perl, html is html, keep them separate)? The code is written by good programmers, they have a firm concept of the way programming is done. But they lack any organized and consistent style, and to quote the senior developer, "I forget how it works, but as long as it works, thats the way it is." Did I miss the class on lapse-of-ethics when I was learning programming in college?

Has anyone else gone through a massive code-audit like this?

thanks
brother dep.

--
Laziness, Impatience, Hubris, and Generosity.


In reply to Why use HTML instead of CGI? (code, discussion) by deprecated

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.