in reply to How do I test a cgi script's subroutines?

The easiest approach is to break it into a separate module; it's really not that difficult.

Alternately, if the invocation is pretty simple, you can wrap everything in main() and call that only if you have no caller.

main() unless caller(); sub main { my $q = CGI->new(); # .... }

Then do or require the script and test it as normal.