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!
| [reply] [d/l] [select] |
Does anyone ever get past the "refer to O'Reilly every 1/2 hour" stage? Of course, as you progress it will be _different_ O'Reilly books that you'll be refering to.
--
<http://www.dave.org.uk>
European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/>
| [reply] |