Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You can also turn code into spaghetti without any unstructured branching constructs, just by judiciously using horrible coding practices in general. I submit to you a snippet from a perl script I wrote some years ago, which is just downright embarassing these days. Note especially the embedded SQL and HTML (with embedded javascript to boot) in the middle of my perl mere lines apart, the obscure variable names, the direct use of array members and references to them, the sloppy formatting, the ultra-long lines, and the painful use of the ternary ? : operator:

$ref=$dbh->selectall_arrayref("SELECT transc.id,transc.state,transc.st +art_date,transc.phys_name,transc.mt_name,org.orgname FROM transc JOIN + org ON (transc.org_id = org.id) WHERE ( transc.state = 4 AND transc. +qa_name='$userinfo{name}' ) OR ( transc.state = 2 AND transc.mt_name= +'$userinfo{name}' ) ORDER BY transc.id"); foreach my $x (@{$ref}) { my $compdis = (filesexist($$x[0],"t") ? "" : qq{disabled="disabled"} +); $$x[2]=~s/...$//; $selfjobs .= qq{<tr><td>$$x[0]</td><td>$whichtype{$$x[1]}</td><td>$$ +x[2]</td><td>$$x[5]</td><td>$$x[3]</td><td>$$x[4]</td><td><input type +="button" value="Files..." onclick='window.location.replace("?fa=$$x[ +0]")' /><input type="submit" value="Complete" onclick='setja($$x[0]," +complete")' $compdis /></td></tr>\n}; }

In reply to Re^3: Spaghetti code... by ph713
in thread Spaghetti code... by davido

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 about the Monastery: (3)
As of 2024-04-23 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found