this program

jdporter on 2002-06-26T21:49:04

Yup, I'm programming in Perl at work.

We had this nasty old perl program floating around, and when I looked into it, I could not believe the insanely bad programming. I'd like to say that the programmer was a converted Fortran hacker, but that would be too generous. I can't even assume that this programmer learned how to write perl by looking at Matt's Scripts. It's more like, he selected about 1 in 5 random lines from perltut, and kept only those bits that worked without modification. As a result, the only array operations he knows about are:

for ( @a )

@a = <F>;

$a[$i] = ...

That's sure not much to go on. He didn't even know how to assign a list to an array. He thought the way to initialize (or "blank out") an array was with

$a[0] = "";

WTF?!!!

He also didn't know about push. In order to add an element onto an array, he would do the following:

open F, "> file"; for ( @a ) { $line = $_; # lord have mercy. print F "$line\n"; } print F "new item\n"; close F; open F, "< file"; @a = <F>; close F;

This was done in about two dozen places in this ~5000 line program. As you can imagine, it ran like a dog.

Also, this programmer knew nothing about lexical variables, subroutine arguments, or subroutine return values. All variables global; no use strict or perl -w. ;-P

(more later...)


D&eacute;j&agrave; lu

vsergu on 2002-06-27T01:14:44

Weren't you telling us about this on the DC.pm list months ago? Not that that's a problem -- such insanity deserves a wider(?) audience.

Re:Déjà lu

jdporter on 2002-06-27T03:03:59

Yes. On both points.
:-)

Yuk

vek on 2002-06-27T04:45:39

I feel your pain. In the next couple of days I'm going to have to modify a (somewhat) smaller program (1876 lines). No strict, no -w. At this point I'm still trying to figure out what the bloody thing actually does :-)