- Make sure this stuff is in a source-code repository. I recommend Subversion, but anything is better than nothing. If your team refuses, you can run subversion in a single-user mode under your home directory.
- The very next step is to write tests that verify what the code is supposed to do. If, as is likely, you cannot get a written spec, write tests against what it does right now.
- Run your testsuite under Devel::Cover, to make sure you got it all. 95% and higher is good.
- Refactor one tiny piece at a time, making sure the testsuite passes every time, verifying that the coverage is always at least as good as before, then check it in.
As for your coworkers ... my experience is that people code in the style they're handed. If you clean things up a bit, then people will continue the trend. It's when there's a broken window that people stop caring. Fix the broken windows and you'll be better off.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?