Bug#521609: Warning: Name "Archive::Tar::WARN" used only once: possible typo

Niko Tyni ntyni at debian.org
Tue Mar 31 18:31:41 UTC 2009


severity 521609 wishlist
retitle 521609 disable obviously spurious 'used only once' warnings
thanks

On Sun, Mar 29, 2009 at 10:42:31PM +0200, Vincent Lefevre wrote:

> OK, I now understand. Then I think that the problem is in perl.
> I suppose that lines such as
> 
>   require SomeModule;
> 
> are seen at compile-time. IMHO, in such a case, perl should disable
> all
> 
>   Name "%s::%s" used only once: possible typo
> 
> warnings for the namespace SomeModule, as they can obviously be
> spurious warnings.

I suppose that would be doable, at least when requiring barewords.

Digging into old discussions a bit, there's an argument that using fully
qualified names for variables in other packages should not trigger
the warning at all.

 http://markmail.org/message/ncocjtek43giv4dw

> >  use vars qw($Archive::Tar::WARN);
> 
> This doesn't seem to be documented and may be annoying if there
> are lots of variables. Also, if the module gets renamed and the
> user modifies only the "require" line, this will defeat the purpose
> of the warning.

It's certainly documented, see 'perldoc vars'. But yes, possibly
not the best way to solve this.

> >  no warnings 'once';
> 
> One doesn't necessarily want to disable all these warnings.

Then put that in a block:

  #!/usr/bin/env perl
  use warnings;
  require Archive::Tar;
  {
    no warnings 'once';
    $Archive::Tar::WARN = 0;
  }
  $Foo = 1;
  
I think this would be my preferred solution.

Downgrading this to wishlist, feel free to bring it up again on the
perl5-porters list if you care enough.
-- 
Niko Tyni   ntyni at debian.org






More information about the Perl-maintainers mailing list