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:
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.
I use eval + symrefs instead of using hashes. I don't even think I knew that hashes existed at that point.
Fun Fun Fun?
for ($i=0; $i<$cutlevelat; $i++)
I also use arrays and linear scans instead of hashes to store the results. Oh boy.
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.
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.)
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||