OK, then I don't get it. I copied your code into my module and ran again with the exact same results (after deleteing "use Whateverelseyouwant;" which caused the expected errors and adding "use CGI qw/:standard/;").

The "use strict;" and "use warnings;" do not become effective in the calling program. As lexical pragmata, I don't see how they could be.

Am I missing something here, or are you just ignoring this issue based on CB with the OP?

Update: I realize I'm not helping people who come here for help by flaming those who attempt to provide solutions. So I promise not to do that anymore and I'm sorry for my previous tone. I also believe, again in the interest of helping those who come here for help, that code that is posted here should either be tested, or clearly marked as untested and I have always tried to do one or the other.

UpUpdate: 3 more ways to see that use strict and use warnings apply by only lexicial scope and not by package:

#!/usr/bin/perl eval qq[ use strict; use warnings; ]; { use strict; use warnings; } sub doit { use strict; use warnings; } doit(); print "$x\n";

As shown, this code produces no warnings or errors. Adding either pragma at file scope has the expected effect.

If you've got proof to the contrary, I'd love to see it.

--Bob Niederman, http://bob-n.com

In reply to Re: Re: Re: Re: Re: Re: Re: Re: How do I make one package use a module from another package? by bobn
in thread How do I make one package use a module from another package? by Anonymous Monk

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.