Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdporter (36)

Journal of jdporter (36)

Wednesday June 26, 2002
04:49 PM

this program

[ #5982 ]

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] = "";


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...)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Weren't you telling us about this on the list months ago? Not that that's a problem -- such insanity deserves a wider(?) audience.
  • 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 :-)