Skip Menu |

This queue is for tickets about the Module-Util CPAN distribution.

Report information
The Basics
Id: 40924
Status: resolved
Priority: 0/
Queue: Module-Util

People
Owner: matt.lawrence [...] virgin.net
Requestors: alexk [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.04
  • 1.05
Fixed in: 1.06



Subject: lexical warnings turned on for File::Find
Hi, again me ;) Turning on lexical warnings for Module::Util leads to a very verbose File::Find::find() call in the Module::Util::_find_modules sub. As a module user of Module::Util it's impossible - at least to my knowledge - to suppress the warnings originating in File::Find::find() without setting the -X perl flag. What about adding a 'no warnings;' just before calling File::Find::find()? A 'no warnings qw(File::Find);' as documented for cases like this in File::Find fails for some reason ... Alexander
I can't replicate this. Can you give an example of what you're doing and what you're seeing? As far as I know, the warnings pragma doesn't work at a distance, so if warnings are originating in File::Find, there's not a lot I can do to suppress them. Also, as far as I'm aware, enabling lexical warnings in Module::Util won't cause them to be enabled anywhere else. e.g. perl -le '{ package Foo; use warnings; sub foo { print undef } } Foo::foo; print undef' Use of uninitialized value in print at -e line 1. -- only one warning appears - use warnings in package Foo doesn't affect main perl -le '{ package Foo; use warnings; sub foo { print undef } } no warnings; Foo::foo' Use of uninitialized value in print at -e line 1. -- no warnings in main doesn't affect Foo $SIG{__WARN__} can be used to trap warnings no matter where they originate. I would consider using that in Module::Util, if there's no cleaner solution. Cheers, Matt On Fri Nov 14 11:30:48 2008, ALEXK wrote: Show quoted text
> Hi, > again me ;) > Turning on lexical warnings for Module::Util leads to a very verbose > File::Find::find() call in the Module::Util::_find_modules sub. As a > module user of Module::Util it's impossible - at least to my knowledge - > to suppress the warnings originating in File::Find::find() without > setting the -X perl flag. > > What about adding a 'no warnings;' just before calling
File::Find::find()? Show quoted text
> > A 'no warnings qw(File::Find);' as documented for cases like this in > File::Find fails for some reason ... > > Alexander
Subject: Re: [rt.cpan.org #40924] lexical warnings turned on for File::Find
Date: Fri, 14 Nov 2008 18:59:51 +0100
To: bug-Module-Util [...] rt.cpan.org
From: Alexander Kühne <alexander.kuehne [...] gmx.de>
Thanks for your quick response. Matthew Lawrence via RT schrieb: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=40924 > > > I can't replicate this. Can you give an example of what you're doing and > what you're seeing? > >
This is what I see when using find_in_namespace() on a Debain Etch with perl 5.8.8 (output slightly abbreviated): perl -e'use Module::Util qw(find_in_namespace); print join( "\n", find_in_namespace("Module"))."\n"; print "warnings: ".($^W ? "ON" : "OFF" )."\n"; ' Can't stat /etc/perl/Module: Datei oder Verzeichnis nicht gefunden at /usr/local/share/perl/5.8.8/Module/Util.pm line 215 Can't stat /usr/local/lib/perl/5.8.8/Module: Datei oder Verzeichnis nicht gefunden at /usr/local/share/perl/5.8.8/Module/Util.pm line 215 Module::Build Module::Util warnings: OFF Show quoted text
> As far as I know, the warnings pragma doesn't work at a distance, so if > warnings are originating in File::Find, there's not a lot I can do to > suppress them. Also, as far as I'm aware, enabling lexical warnings in > Module::Util won't cause them to be enabled anywhere else. > > e.g. > > perl -le '{ package Foo; use warnings; sub foo { print undef } } > Foo::foo; print undef' > Use of uninitialized value in print at -e line 1. > > -- only one warning appears - use warnings in package Foo doesn't > affect main > > perl -le '{ package Foo; use warnings; sub foo { print undef } } no > warnings; Foo::foo' > Use of uninitialized value in print at -e line 1. > > -- no warnings in main doesn't affect Foo > > >
File::Find is making use of warnings::register and warnings::warnif (see perldoc warnings) which are working from the caller's perspective. Hence saying "no warnings 'File::Find';" in Module::Util prior to the call of File::Find::find should suffice for suppressing the warnings originating in File::Find. For some reason that I could not track down yet, passing the warnings category File::Find as described in the docs of File::Find fails. But saying "no warnings;" is OK. As to the lexical nature of the warnings pragma putting "no warnings;" within Module::Util::_find_modules should not affect the rest of the code regarding warnings in Module::Util. Cheers, Alexander Show quoted text
> $SIG{__WARN__} can be used to trap warnings no matter where they > originate. I would consider using that in Module::Util, if there's no > cleaner solution. > > Cheers, > > Matt > > >
Show quoted text
> On Fri Nov 14 11:30:48 2008, ALEXK wrote: >
>> Hi, >> again me ;) >> Turning on lexical warnings for Module::Util leads to a very verbose >> File::Find::find() call in the Module::Util::_find_modules sub. As a >> module user of Module::Util it's impossible - at least to my knowledge - >> to suppress the warnings originating in File::Find::find() without >> setting the -X perl flag. >> >> What about adding a 'no warnings;' just before calling >>
> File::Find::find()? > > >
>> A 'no warnings qw(File::Find);' as documented for cases like this in >> File::Find fails for some reason ... >> >> Alexander >>
> > >
As far as I know, this is fixed in the latest version.