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??

Here's one I deal with at my present job. This isn't a mistake by an intern, but production code relied on by many people.

Instead of writing a module that you include into your code, system X was implemented as a program which reads in your code! You invoke it as system_X my_customization_code.pl

Then system X reads in your file and evals it. But compilers don't know about comments, so comment lines are skipped:

# Read in configuration parameter file open (FILE,"<$scriptFile") || die "Cannot open $scriptFile"; while (<FILE>) { # Remove comments $script .= $_ unless /^\#/; } close FILE; eval $script; die "$@" unless $@ eq "";

Besides the foolishness of having things backwards, using eval on a string instead of on a file name means that when I debug code ( M-x perldb in emacs ), the system doesn't know where the source code is located and so cannot display it. But that wasn't enough for the villain who wrote this .... by skipping comment lines, the line number displayed by the debugger bears no relation to the actual line in the file.


But I have found a way to beat the system, considering I cannot change the basic system X files. My include file is short, and requires other files, which contain my actual code. So the eval reads in the files which contain my real code, and the debugger works. For debugging purposes, I have my own copy of system X which does not skip over comments, since the Perl compiler can handle that without my help.

--
TTTATCGGTCGTTATATAGATGTTTGCA


In reply to Re: The joys of bad code by TomDLux
in thread The joys of bad code by BUU

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 chanting in the Monastery: (7)
As of 2024-04-25 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found