I know that feeling. And beleive me it gets worse as you grow older in/with perl. The other day I caught myself blushing while reading my own code! I had to alter stuff that I had done a couple of years ago, and downloaded a script that had been working for that period of time.

This particular system was using flatfiles to generate a product list, and keep track of orders posted via web. Something in the lines of a pre-historic shopping cart, if you will. Well, to get the bottom of it, I found things in the script like: (please note the lack of my and local usage)
@tmp = <FILE>; foreach $line (@tmp) { chop $line; ($foo,$bar) = split(/\t/,$line); $HASH{$foo} = $bar; } foreach $key (keys %HASH) { print "<some html>$key - $HASH{$key}</some html>\n"; }
... and other pearls of the sort! (pun intended) I'm sure at the time I thought I had a good reason to hash and then loop the hash, but now, looking at the file, I fail to find it. If I had to re-write the entire script nowadays, I'd do it in a very different fashion. Maybe something in the lines of:
while (<FILE>) { m/(^.*)\t(.*$)/; print "<some html>$1 - $2</some html>\n"; }
Come to think of it, even the HTML is so bad that I would do it a different way! I dunno, at this point I'm just rambling. I don't think that this feeling is ever going to get any better. Maybe in two years I'll look back at the stuff I'm doing today and go EEEEK! And maybe four years from now I'll look back on the stuff that I'll do in two years and go EEEEK! as well? Who knows...

#!/home/bbq/bin/perl
# Trust no1!

In reply to RE: RE: it is amazing sometimes how little you know... by BBQ
in thread it is amazing sometimes how little you know... by Buckaroo Buddha

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!
  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.