Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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


In reply to Re: Pearls (not really) of Perl programming by jryan
in thread Pearls (not really) of Perl programming by PetaMem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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:
    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
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (22)
    As of 2014-08-22 16:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (161 votes), past polls