in reply to CGI script and captcha input

You can't let a CGI script wait for input.

CGI works this way: you deliver pages to the user, and when they are displayed, the user choses to fill in forms and send them - or he doesn't.

To implement what you're about to you need a way to introduce state, that can be achieved with cookies that store session informations.

Take a look at CGI::Session::Tutorial, it should help you.