in reply to Pearls (not really) of Perl programming

Here is some code that I wrote almost 5 years ago. It was my first real Perl program; I had previously been a PHP programmer, and really had no clue what I was doing at the time when I wrote this. Really, read the code; I think it really tops anything anyone has posted in this thread so far. I'd be embarassed about it, but is *just* *too* *funny*.

Among the highlights:

  1. Probably the most gratuitous use of eval I've ever seen. I use eval here for everything from recursively calling a function (I think to avoid infinite recursion warnings) to simple assignments.
  2. I use eval + symrefs instead of using hashes. I don't even think I knew that hashes existed at that point.
    for ($i=0; $i<$cutlevelat; $i++) { eval("\$n".$i."=0"); }
    Fun Fun Fun?
  3. I also use arrays and linear scans instead of hashes to store the results. Oh boy.
  4. I remember having to research "my" when I was writing this. You might notice that the recursive subroutine uses "my" with its variables while the rest of the program doesn't. This wasn't because I had discovered lexical scoping halfway through writing this. This was because I couldn't figure out a consistant way to do it with eval.
  5. And the fun goes on and on...

Despite all of these problems, the program had some pretty cool functionality. It would scan a condendensed apache log file (which I condensed with another script that ran as a cron job) and turned it into a heirarchy view that told how many hits each page on our school's website got, with higher levels having the sum of the hits on the lower levels.

So, it might be total garbage, but it just shows how far I've come, right? :)

(P.S.: I remember being confused as to why the node recieved such a high rep, because I knew it was garbage when I posted it. (it was my 3rd node on this site). It wasn't until later that I learned that people often voted on frontpaged nodes without reading them.)