in reply to Refactor huge subroutine

All,

Thanks for commenting. I do have test suites in place, so it'll ensure not to break thing during refactoring.

I'll try to put all the suggestion here to my code, however the thing that still scary me is that log if-elsif-else block. I've considered moving that into subroutines, but have no idea with the implementation.

Thanks.