Change use Strict; to use strict;

Short explanation: The name of the module is strict, all lower case. Because Windows is case insensitive, use Strict; will load the module even though it is already loaded. It won't do anything useful with it, but it will load it. Since it was already loaded by something else (or else something else loads it after you did), you get redefinition warnings and no useful effect. Change it to the proper case and you'll have no redefinition warnings, and the module will do something for you.

Long explanation. When you type use Strict; Perl proceeds to do the following:

BEGIN { require Strict; Strict->import(); }
require checks %INC to see whether "Strict.pm" is loaded, and then tries to load it if not. However %INC is case sensitive, so it won't notice that Strict.pm is there if it is looking for strict.pm, and vice versa. Since Windows is case insensitive, if you look for Strict.pm you'll find strict.pm. So Perl decides it doesn't have the module, and tries to load it. Since you're loading the same code twice, you get redefinition errors.

Your bigger problem, though, is that the line Strict->import(); won't do anything useful. You see strict.pm only implements strict::import. So there is no Strict::import to find, and nothing happens.

So make it use strict; and Perl will not try to reload the same module, and (more importantly) Perl will make the method call that turns strict on in your code.


In reply to Re: use Strict: a rigorous way to break my command line variables? by tilly
in thread use Strict: a rigorous way to break my command line variables? by NamfFohyr

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.