- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frist time I see structured Perl
Admin
Something funny about Perl is that I couldn't ever find a script in the wild split in more than one file and I'm sure the language absolutely allowed so. Some scripts were HUGE.
Admin
as opposed to seeing a script split into exactly one file, which may be oxymoronic. (sorry, couldn't resist. it's time for my medicine.)
Admin
There are a ton of far better examples of well structured and well formatted Perl code out there. Anyone can also write painfully unreadable code in any other language too.
Admin
Have a look around metacpan.org and you'll quickly find that a lot of code is in logically separated into reusable classes, in separate modules files.
Admin
Pffffffft. Where I work, we have an automated test system (it's plenty WTF itself) that has three-quarters of a million lines of Perl across 1654 files.
Admin
Oh, do tell (or submit a few) :)
Admin
That actually looks like quite nice perl code! We had something similar at <DAYJOB> until just a couple years ago, although it was bigger and split across multiple script files.
The WTF here is, surprisingly, not the code, but what the code is doing.
Admin
The conspicuous issues I see here are: ragged indentation, intrusive here-documents, and use of the pointless if-not statements (unless). Each is trivial to improve upon. Explicitly putting "m" before match expressions mitigates one of Perl's worst readability problems and always gets a +1 from me. Overall, relatively sane Perl.
TRWTFs are procrustean tools like Ant and Maven that are flexible in every way except the ones that your build requires.
Admin
It's hard to point out individual illnesses in it, because it's mostly systemic, a system that initially was just cobbled together with a lot of "OK, just kinda sorta make it work", whereupon, over the course of a dozen years or so, it "just growed". That, of course, led to it kinda sorta working. Thanks to the efforts of some of the more recent arrivals in the QA group (over the last six or seven years), people who have taken a more disciplined "I'm a developer of tests" approach (rather than "a tester who programs"), some of it has become progressively better, or at least less awful.
But it's still in need of more treatment, more "-dependency" option infrastructure, for example, so you can point to that one test there and launch its individual set-up dependencies automatically rather than having to know and/or work out what they are every time you need to run it.
Admin
Yes, but other languages don't make a cultural virtue out of it.
Admin
What a horrid monstrosity (the ListWrapper) ... what happens if you use iterators to delete (or even ListIterators to add?) Or subLists?
If you're going to wrap collection classes, look at what they're doing in the Collections class (synchronized and unmodifiable collections, e.g.)
This is not how you do it! SHIVER
Admin
I know a bit of Perl and I still didn't look at that code.
Admin
Golfing may be a popular thing in Perl, though I have seen worse "professional" and "enterprise" code in other languages that were more difficult to decipher.