This is definitely something you should not see. It is a bug. As you didn't indicate your perl version, I cannot say whether it is worth to report as a bug. If it is 5.8, definitely report it.
For the time beging, you can set environment variable PERL_DESTRUCT_LEVEL to 2, see whether it works, usually it does. If not, play with even lower values.
BTW, just in case, this sounds like a good oppotunity for using things like CGI, HTML::Template etc. Did you use those?
Update:
Lhamo Latso, I saw your reply to
graff, but this is still a Perl bug. Regardless how you use it, Perl destruction process itself should work gracefully. If you are using 5.8, I suggest you to keep a version of your "bad" code, and report this bug.