On Fri Apr 23 23:44:14 2010, bill.n1vux@gmail.com wrote:
Show quoted text> "I wish I could use Config::Std with use warnings, without getting any
> warnings."
>
> That seems like a very reasonable goal ! strict and warnings should be
> harmless. I consider that a prerequisite for moving to 1.0.
>
> FYI, I have recently taken over the module maintenance from Damian, and am
> prioritizing things for clean-up. First release will be mostly Doc fixes.
>
> Thanks for the input. And thanks for including a test.
>
> bill in Boston
>
Hi Bill,
Thanks for the quick response. But I realize I was wrong to think the
warning was produced because I had used 'use warnings'. The warning
comes from Class::Std which has 'use strict' and 'use warnings' itself.
The problem could be fixed in Class::Std, by adding "no warnings
'once';" in sub DESTROY:
sub DESTROY {
my ($self) = @_;
my $id = ID($self);
push @_, $id;
DEMOLISH: for my $base_class (_hierarchy_of(ref $_[0])) {
no strict 'refs';
no warnings 'once';
if (my $demolish_ref = *{$base_class.'::DEMOLISH'}{CODE}) {
&{$demolish_ref};
}
for my $attr_ref ( @{$attribute{$base_class}} ) {
delete $attr_ref->{ref}{$id};
}
}
}
I am suspicious of this line:
bless $hash_ref, 'Config::Std::Hash';
in read_config in package Config::Std::Hash. I don't see anything in the
Class::Std documentation suggesting such use.
With the following main routine:
#!/usr/bin/perl
use MyClass;
my $obj = MyClass->new();
This implementation of MyClass produces the warning:
package MyClass;
use Class::Std;
my $hash_ref = {};
bless $hash_ref, 'MyClass';
1;
But this one doesn't:
package MyClass;
use Class::Std;
{
my %name_of : ATTR;
}
1;
Both implementations cause the Class::Std DESTROY subroutine to be run.
I don't understand why one produces the warning and the other doesn't.