Wow, I have never seen "warnings" used as
an invocant to a method call before.
I'm currently using:
use Exporter 'import';
our @EXPORT = qw ( stuff );
but I'll rewrite it to use an import() subroutine and
Exporter's export_to_level() call instead.
Thanks,
Greg
> If your module has an import method, and in that method calls
> warnings->unimport("once") then the unimport should be lexically
> scoped to where your package was used. Which in the normal case is
> the whole file, so it works.
>
> On Sat, May 4, 2013 at 2:07 PM, Jordan Adler <[email protected]>
> wrote:
>> This pragma usage is lexically scoped, too.
>>
>> Sent from my iPhone
>>
>> On May 4, 2013, at 5:01 PM, Jordan Adler <[email protected]>
>> wrote:
>>
>>> Design issues aside,
>>>
>>> no warnings 'once';
>>>
>>> Sent from my iPhone
>>>
>>> On May 4, 2013, at 3:47 PM, "Greg London" <[email protected]> wrote:
>>>
>>>>> is there a way to suppress this warning from inside testpackage.pm
>>>>> somehow?
>>>>
>>>> I've tried a bunch of things and still haven't found a solution.
>>>>
>>>> Is this not possible to do in per?
>>>> Or is it so obvious I can't see it?
>>>>
>>>> Greg
>>>>
>>>>
>>>>>
>>>>> package file testpackage.pm:
>>>>>
>>>>> package testpackage;
>>>>> use warnings;
>>>>> use strict;
>>>>> use Data::Dumper;
>>>>> use Exporter 'import';
>>>>> our @EXPORT = qw ( somesub );
>>>>> sub somesub{
>>>>> my ($name)=@_;
>>>>> my @caller=caller(0);
>>>>> my $package=$caller[0];
>>>>> my $evalstr = '$'.$package.'::'.$name.' = 42;';
>>>>> eval($evalstr);
>>>>> }
>>>>> 1;
>>>>>
>>>>>
>>>>> script file testscript.pl:
>>>>>
>>>>> #!/usr/bin/env perl
>>>>> use warnings;
>>>>> use strict;
>>>>> use testpackage;
>>>>> somesub('tricky');
>>>>> print "hello, tricky is '$main::tricky'\n";
>>>>>
>>>>>
>>>>> When I run this script, I get the warning:
>>>>> Name "main::tricky" used only once: possible typo at ./testscript.pl
>>>>>
>>>>>
>>>>> is there a way to suppress this error from inside testpackage.pm
>>>>> somehow?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Boston-pm mailing list
>>>>> [email protected]
>>>>> http://mail.pm.org/mailman/listinfo/boston-pm
>>>>
>>>>
>>>> --
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Boston-pm mailing list
>>>> [email protected]
>>>> http://mail.pm.org/mailman/listinfo/boston-pm
>>
>> _______________________________________________
>> Boston-pm mailing list
>> [email protected]
>> http://mail.pm.org/mailman/listinfo/boston-pm
>
--
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm