in reply to calling sub routine problem?

It would appear that you are calling the sub in your script before (that is: above the place where) you define it.

If you don't want to move the full subroutine declaration to the top of your file, you can just put the sub / prototype declaration near the top and then spell out the whole subroutine later.