Having written some truly ugly Perl back when I was starting as a consultant, I understand how a little 250 line script can grow to 8000 lines when the person who's paying the bills says things like "Re-write? Are you crazy? We don't have time! Stick in this new feature, and have it done by Tuesday!!".
You've already received some great advice -- just pop back here when you run out of brain cells and we'll help you as best we can. Probably the best advice is to version control as much of this as you can -- being able to 'roll back' to the previously working version is priceless. If you're running Linux, check out rcs -- very simple, but very solid. Failing that (like, if you're on Windows), make new sub-directories for each version. Not quite as convenient, but still very useful.
Good luck!
--t. alex
Life is short: get busy!