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:
strictandwarnings.pm after "fix":#!/usr/bin/perl use strictandwarnings; # use strict; # use warnings; # my $x; print "$x\n"; $x = '$y'; print header(), start_html(), "\n";
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:showing that had your code worked, the rpgram shouldn't have.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.
recomment use strict and uncommmment use warnings in t100.pl and it produces:
followed by the correct output.Use of uninitialized value in concatenation (.) or string at ./tst100. +pl line 9.
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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |