develooper Front page | perl.perl5.porters | Postings from April 2007

Re: [perl #42601] Inconsistent warning of redefined subroutines in Exporter

Thread Previous | Thread Next
Rick Delaney
April 19, 2007 11:30
Re: [perl #42601] Inconsistent warning of redefined subroutines in Exporter
Message ID:
On Apr 19 2007, Nicholas Clark wrote:
> On Thu, Apr 19, 2007 at 10:05:30AM +0200, Rafael Garcia-Suarez wrote:
> > On 18/04/07, via RT Colin Robertson <> wrote:
> > >Running "perl -we 'use Once;'" gives us no warnings, but running "perl
> > >-we 'use Once; use Twice;'" gives us:
> > >
> > >Subroutine Twice::foobar redefined at
> > >/usr/local/lib/perl5/5.8.7/ line 65.
> > > at line 4
> > >
> > >Ideally, there should have been a warning just when compiling Once.
> > 
> > I get a warning with only with perl 5.8.8 (and also bleadperl
> > and peprl 5.6.2). Not sure what has changed since 5.8.7...
> It might be this one. From perl588delta.pod:
> =head2 no warnings 'category' works correctly with -w
> Previously when running with warnings enabled globally via C<-w>, selective
> disabling of specific warning categories would actually turn off all warnings.
> This is now fixed; now C<no warnings 'io';> will only turn off warnings in the
> C<io> class. Previously it would erroneously turn off all warnings.
> This bug fix may cause some programs to start correctly issuing warnings.
> =cut

That seems pretty likely, since Carp::Heavy (ultimately loaded by
Exporter) has a C<no warnings "once";> in it.  I believe the workaround
for this in older perls is to make sure to use warnings before anything
else.  So for Colin's test, try

    perl -we 'use warnings; use Once;'

And for the in-the-wild case:

    use warnings;
    use File::Slurp;
    use File::Temp;

Rick Delaney

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About