As the Anonymous Monk suggested, you may be able to speed this up by processing the hosts in parallel. Another option, in addition to those suggested, may be Parallel::ForkManager.
I did not look at your code (thus, the "may be" above). For future posts, please post your code in the post itself (surrounded by <code></code> tags, and possibly <readmore></readmore> tags if very lengthy)-besides being more convenient to those who may have only a limited time to consider your post when they first see it, it also helps to preserve the context for answers that may be posted (as, if memory serves, most PasteBin sites expire the code after some time, thus removing the context for readers who may find this post months or years from now if it relates to an issue they are having).
Hope that helps, and that you find the information you seek.