in reply to shortin this code up

You have bigger problems than the length of your code.

You should use strict.pm. Get rid of your globals. Using select * in anything that you don't want to break is silly. Using it with positional logic means that you don't want to understand your code, you don't want anyone else to either. Plus you had better be planning on rewriting it in a hurry at the worst possible time. Because you will have to whenever someone rebuilds the database table and moves columns around on you. Fixing all that is a minimum.

And just in case you have bought into the peculiar stupidity which says that unreadable code provides "job security", it doesn't. Deliberately produce crap, and it will be cheaper for your employer to fire you and rewrite it. The sooner the better so that you have produced less to rewrite. (They admittedly often don't realize this fast enough.)