in reply to How to write better code?

Depending on where the $string comes from, the answer might be use CGI; Cheers.