in reply to Re^2: mkpath (and rmtree) throw strange error when used in CGI
in thread mkpath (and rmtree) throw strange error when used in CGI

So some part of your script actually prints out something before the header is printed. Maybe a left-over debugging statement?

Or do you have any environment variables with debug in the name?