Rants on bad (Perl) programming remind me of a former employee (that I kind of inherited).

To get the length of a string he coded this little bit:

$string="the quick brown fox"; @temp=split //, $string; $string_length=$#temp; $string_length++; undef @temp;
Duh! What happened to "length $string"? Do you honestly think that Perl does NOT have a function to obtain the length of a string? Do you know ANY modern language that does not have such a function? And, no, its not like he was some sort of newbie.

I didn't know whether to slap him upside the head, laugh, cry or fire him on the spot. Then my mind wandered to the notion that this guy has and will leave a path of destruction in his wake. I hope that he moves over to writing in Java sometime soon. :)

J

Update: Corrected his code I pulled from memory. I had forgotten about the increment statement too. So, now it is four lines to do what you could do in 1... If we work at this we could make it worse, no?


In reply to How NOT to do it by jlawrenc

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.