Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Comment on

( #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

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.


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

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [Veltro]: Lol, think this is the best one: Why donít I just use Googleís thing? -You think thatís going to be around in 6 months?

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (7)
    As of 2018-05-24 12:37 GMT
    Find Nodes?
      Voting Booth?