in reply to -w switch and subs
Does the script ever finish, or do you have to kill the process? It sounds like perhaps sub B calls sub A and you're getting deep recursion.