in reply to problem with substituting

Every time I substitute these variables only the $code variable prints. I never see the $stats variable print.

I don't see the print statements. How are you printing $stats, and how is that different from the way you print $code?

'Course, I don't know much about CGI, so maybe that HTML comment is what you're talking about.