Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-29 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found