The 'use strict' and 'use warnings' are absolutely NOT 'imported' into the calling scope.

I don't need your help writing a test case. Apparently you need mine. Here it is:

t100.pl:

#!/usr/bin/perl use strictandwarnings; # use strict; # use warnings; # my $x; print "$x\n"; $x = '$y'; print header(), start_html(), "\n";
strictandwarnings.pm after "fix":
package strictandwarnings; require Exporter; our @ISA = qw(Exporter); sub import { my ($pkg) = (caller)[0]; my $current = __PACKAGE__; eval qq[ package $pkg; use strict; use warnings; use CGI qw/:standard/; package $current; ]; # optionally, if you still need import: goto \&Exporter::import; } 1;

t100.pl as is runs to completion with no warnings.

Un comment 'use strict' in t100.pl and it barfs with:
Global symbol "$x" requires explicit package name at ./tst100.pl line +9. Global symbol "$x" requires explicit package name at ./tst100.pl line +11. Execution of ./tst100.pl aborted due to compilation errors.
showing that had your code worked, the rpgram shouldn't have.

recomment use strict and uncommmment use warnings in t100.pl and it produces:

Use of uninitialized value in concatenation (.) or string at ./tst100. +pl line 9.
followed by the correct output.

Your initial code said it did 3 things. It did none of them. 3 is more than 1. Hence 'multiply broken'.

And the OP did in fact use 'use strict' and 'use warnings' in the oringinal post. SOrry for not being a mind reader.

Note to whoever else keeps --'ing me: Have you tried to test the code, or do you just beleive this other guy when he says it works? Update: the original version of previous was much harsher, suspect that that is what was dissed.

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

In reply to 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.