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?


In reply to Re: best way to handle Subroutine redefined warning by ww
in thread best way to handle Subroutine redefined warning by keiusui

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.