Need Help with Perl REGEXP

I need help with a Perl regular expression.
The following string blows up my program: <david(greg jim)>
If I type this string, there is no problem: <david(greg_jim)> or type
david(gregjim) or type <david greg jim> the CGI program does not complain.

For some reason that I do not understand the string david(greg jim) returns the error "did not produce a valid header."

Is there anybody out there that can help me with a regexp that can prevent the CGI error. This string works: david(greg) jim; therefore, I was thinking of maybe adding the right param.

Any thoughts?
Thanks in advance for your help.

Regards,
Dave

I don't understand your problem at all. Can you explain in more detail please, maybe produce the shortest excerpt of source code that you can still reproduce the error, and list the input concerned, and what are the output?

Assuming your script is a CGI script, output of errors may mean a lot of things, and it depends on your script itself.