Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

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

I'm not going to quibble with the basic thrust of your advice, but the following quote struck my eye:

The above code is obfuscated seemingly for the sake of obfuscation.

What leads you to say that? Because it uses the ternary operator? The first thing I noticed about the code is that it put each significant chunk on its own line. That hardly seems like the practice of a determined obfuscator. Apart from the issue of whether or not a given developer is familiar with the ternary operator, it boils down to :

$db = [connection specification] or die;
which is plain 'ol idiomatic Perl.

There are a number of reasons one might write code like that, having nothing to do with obfuscation. Perhaps the original author liked the terse idiom and compensated for it by formatting the code the way s/he did. Maybe s/he had five minutes and somebody asked her/him to make the script use a different connection if it was running on a specific server.

Of course, if you're going to rewrite it for later expansion, you might as well move the connection selecting code off into its own subroutine or, if it's complex enough, module. But I think we should all be aware that developers don't always have the time to develop code like that right from the very start -- especially when you don't know whether your code is going to be in use two weeks after you write it, which is a distinct possibility.

If not P, what? Q maybe?
"Sidney Morgenbesser"


In reply to Re: (3) Ternary confusion by arturo
in thread Ternary confusion by Nik

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 making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found