in reply to Refactor huge subroutine

  1. Move code in nested for/while loops into their own subroutine.
  2. Move the giant if/elsif conditions into their own subroutine and refactor till it makes sense.
  3. 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...
  4. If you have a subroutine that is longer than the size of your screen (80 rows or so) it is too long.
  5. 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.