in reply to redirection in perl

Sounds like you're printing the headers twice. The headers you describe are correct for a redirect (if $homepageurl is a real URL). If they're showing up on the web page it's because other headers were printed (or automatically sent/output by the server in some edge configuration cases) first.

redirect outputs headers so if you're also doing print header()... you need to put it into a logic check (like if/else) so you only print one set of headers.