Thanks for the solution
I think 2nd method which you told is suitable to test my scripts.
I am new for testing and can you please explain what is "# Main routine here" and "... rest of implementation here..." and "__PACKAGE__->run() unless caller();"
you have told to "write tests for the subs in it" what it means?????