http://qs321.pair.com?node_id=294763


in reply to Worst thing you ever made with Perl

Hi Juerd,
That's kinda freaky as just today I looked at some code I wrote 10 years ago. It was my first public facing script capturing input from a HTML form page. I couldn't stop laughing, it was 500+ lines long, today I could condense it to 40 lines (or less with a bit of golf).

To continue the laugh, back then due to the fact I didn't go to college or Uni (fully self taught) I had no concept of Db's, flatfile or relational and for the big giggle I'd sussed array's but had no idea what the hell a hash was (in those days known as an associative array).

It was truly awful, no security, no error checking and certainly no sanity checking. I hadn't heard of CPAN yet either (not to mention POD, so yup, comments like "# This sub does stuff" were in there too).

So ++ to you for bringing this up, I have learnt much since, from work colleagues and from the monastery. I'm still chuckling now with some of the syntax that I remember from "back in the day" that 'seemed' logical at the time but "oh dear" was just "wrong, wrong, wrong".

That's made my day that has, thank you.

Replies are listed 'Best First'.
Re: Worst thing you ever made with Perl
by jonadab (Parson) on Sep 29, 2003 at 14:03 UTC

    Speaking of POD... up until now, I've been just using comments, as I would in any other language. Is there a very simple tutorial I could pick up someplace that would show me how to write my comments as POD, in a fashion that would be mostly transparent during coding but potentially useful later on? POD has been on my to-learn list for a few months now... maybe it's time to pick it up...


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
      Hiya jonadab,
      Here's a quick online POD page link (which I printed off and stuck to my wall as a reference tool).

      As for POD coding style, that's something you'll have to develop yourself.

      HTH

        Both of these tutorials, nice though they may be, talk mainly about how to stick one big block of documentation at the top or bottom of the whole file. For me that would be a step backwards. I'm MUCH more interested in documenting each function locally, right near the top of that function, (usually, right below the line that pulls @_ into named lexicals) like I would do with comments. I've been led to believe this is possible with POD, which is why I asked. Doing it this way makes it easier to compare the documentation of what the function does with the function itself, which makes for easier maintenance. Yes, I know I can split my window in Emacs and put the doc in one half and the code in the other, but a lot of times I like to put two sections of code in the two halves, and when I start splitting vertically into three parts, I find that it puts too much crimp on how many lines I can see at once. Maybe what I really need is a larger monitor, but until then, I'd like to keep the docs for each function together with that function.


        $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/