Move code in nested for/while loops into their own subroutine.
Move the giant if/elsif conditions into their own subroutine and refactor till it makes sense.
Making this into an object would simplify refactoring(for the if/elsif checks) because you can make a subroutine to do the conditional check that is more descriptive than 3 or 4 lines of
if $blah == 2 and $blah2 < 2 and etc...
If you have a subroutine that is longer than the size of your screen (80 rows or so) it is too long.
If you have lines of code that are stretching over 80 lines in length then try another way to write the code. There is nothing worse than missing something because it goes off the screen.