horrendo has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am trying to become familiar with Damians Class::Std, and I am getting these redefine warnings when I run my code :
Subroutine UNIVERSAL::VERSION redefined at /usr/lib/perl5/5.8.0/i386-l +inux-thread-multi/DynaLoader.pm line 249. Subroutine UNIVERSAL::can redefined at /usr/lib/perl5/site_perl/5.8.0/ +Class/Std.pm line 506.
I've tried this on Perl 5.8.0 on RHEL 3, and 5.8.6 on Cygwin with the same result (although different line number in DynaLoader.pm).

I'm sure it is something stupid I'm doing, but can't figure out what. Here is my class definition :
package TestBase; use strict; use warnings; use Class::Std; { my %prop1 : ATTR( init_arg => 'prop1' get => 'prop1' set => 'prop1 +' ); my %prop2 : ATTR( init_arg => 'prop2' get => 'prop2' set => 'prop2 +' ); 1; }
and here is the script :
#!/usr/bin/perl -W use strict; use warnings; use TestBase; my $b = TestBase->new( { prop1 => 'hello', prop2 => 'world' } ); print $b->_DUMP ; print 'b->prop1 = ' . $b->get_prop1 . "\n"; print 'b->prop2 = ' . $b->get_prop2 . "\n"; $b->set_prop1('horrendo'); $b->set_prop2('revolver'); print $b->_DUMP ;
I know the warnings aren't fatal, but I would prefer they weren't there. I checked the code in Class::Std and just before the eval that generates the warning, there is a line
no warnings 'redefine';
I would have thought this would suppress the warning.

I appreciate your help.

Regards,

Steve

Replies are listed 'Best First'.
Re: Class::Std redefine warnings
by itub (Priest) on Aug 11, 2005 at 18:50 UTC
    The problem is that you are using the (uppercase) -W option, which means "force all warnings, even if the code tries to turn them off".
      That was it. Thanks !!