in reply to best way to handle Subroutine redefined warning

Apologies for this mess which is rooted in my careless misreading of the terminal when I initially ran the script.

Your script, as is (presumptively, minimized for posting See para 3), run from the CLI doesn't do what you say it does. In fact, it compiles and runs quite cheerfully, printing the 'sub redefined' message and 'Content-Type:text/html...this is a test' The sub is never called, so it can't produce the message you cite.

Were you to include just before or after the comment in the sub, an instruction that actually does something (for example, print "inside sub redir \n";, the problem you assert would manifest itself.

Please, test code before posting to make sure it comports well with your problem description. Yes, we advocate posting a minimal sample of your code, but NOTE that's modified by the qualifier "working." <=true but irrelevant

We've been promised that our crystal balls will be fixed by Tuesday, but we don't know which Tuesday of which year. On the other hand, from the excellent analyses in the replies above, maybe it's just mine that's on the fritz.

Update: I failed to see the "redefined" message between the CLI and the output produced by OP's lines 9 and 10. After reading chromatic's reply, I reran OP's script, and spotted the 'redefined' message. So I've now added acknowledgment of its appearance and have stricken my inaccurate/imprecise (eg, "wrong") statements above.
But, since the code compiles and executes (from a W32 CLI perl -T 890026.pl, isn't the message a warning (as outlined above by toolic) rather than a compiler error?

Replies are listed 'Best First'.
Re^2: best way to handle Subroutine redefined warning
by chromatic (Archbishop) on Feb 24, 2011 at 21:09 UTC
    The sub is never called, so it can't produce the message you cite.

    The "subroutine redefined" warning is a compile-time warning. Whether that code is reachable is irrelevant.