Skip Menu |

This queue is for tickets about the Config-Std CPAN distribution.

Report information
The Basics
Id: 56862
Status: resolved
Priority: 0/
Queue: Config-Std

People
Owner: BRICKER [...] cpan.org
Requestors: Ian.Goodacre [...] xtra.co.nz
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: v0.0.4
Fixed in: 0.903



Subject: Warning: Name "Config::Std::Hash::DEMOLISH" used only once: possible typo at /usr/share/perl5/Class/Std.pm line 523.
The subject warning is issued when 'use warnings;' is in effect. I wish I could use Config::Std with use warnings, without getting any warnings. I am testing on ubuntu 9.10 with perl vesion 5.10.0 and Class::Std version 0.0.9. There are two parts to my test program: a main program - test.pl: #!/usr/bin/perl use warnings; use Test::Config; And a module - Test::Config: package Test::Config; use Config::Std; my %config; read_config('xxx.conf' => %config) or die; 1; The config file (xxx.conf) exists but is an empty file.
Subject: Re: [rt.cpan.org #56862] Warning: Name "Config::Std::Hash::DEMOLISH" used only once: possible typo at /usr/share/perl5/Class/Std.pm line 523.
Date: Fri, 23 Apr 2010 23:43:41 -0400
To: bug-Config-Std [...] rt.cpan.org
From: Bill Ricker <bill.n1vux [...] gmail.com>
"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 -- Bill n1vux@arrl.net bill.n1vux@gmail.com On Fri, Apr 23, 2010 at 2:31 PM, Ian Goodacre via RT < bug-Config-Std@rt.cpan.org> wrote: Show quoted text
> Fri Apr 23 14:31:50 2010: Request 56862 was acted upon. > Transaction: Ticket created by iang > Queue: Config-Std > Subject: Warning: Name "Config::Std::Hash::DEMOLISH" used only once: > possible typo at /usr/share/perl5/Class/Std.pm line 523. > Broken in: v0.0.4 > Severity: Wishlist > Owner: Nobody > Requestors: Ian.Goodacre@xtra.co.nz > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=56862 > > > > The subject warning is issued when 'use warnings;' is in effect. I wish > I could use Config::Std with use warnings, without getting any warnings. > > I am testing on ubuntu 9.10 with perl vesion 5.10.0 and Class::Std > version 0.0.9. > > There are two parts to my test program: a main program - test.pl: > > #!/usr/bin/perl > use warnings; > > use Test::Config; > > > And a module - Test::Config: > > package Test::Config; > > use Config::Std; > > my %config; > read_config('xxx.conf' => %config) or die; > > 1; > > > > The config file (xxx.conf) exists but is an empty file. >
From: Ian.Goodacre [...] xtra.co.nz
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.
Subject: Re: [rt.cpan.org #56862] Warning: Name "Config::Std::Hash::DEMOLISH" used only once: possible typo at /usr/share/perl5/Class/Std.pm line 523.
Date: Sat, 24 Apr 2010 11:47:16 -0400
To: bug-Config-Std [...] rt.cpan.org
From: Bill Ricker <bill.n1vux [...] gmail.com>
Thank you again, more grist for the mill. -- Bill n1vux@arrl.net bill.n1vux@gmail.com
Subject: Re: [rt.cpan.org #56862] Warning: Name "Config::Std::Hash::DEMOLISH" used only once: possible typo at /usr/share/perl5/Class/Std.pm line 523.
Date: Sun, 25 Apr 2010 11:46:24 +1200
To: bug-Config-Std [...] rt.cpan.org
From: Ian Goodacre <Ian.Goodacre [...] xtra.co.nz>
Hi Bill, I still don't understand why the warning is issued in some cases but not others, but there is a simple workaround that can be implemented in Config::Std: add a sub DEMOLISH to Config::Std::Hash. I did so as follows for testing: diff -u /usr/share/perl5/Config/Std.pm Config/Std.pm --- /usr/share/perl5/Config/Std.pm 2010-04-25 11:43:15.000000000 +1200 +++ Config/Std.pm 2010-04-25 11:37:05.000000000 +1200 @@ -459,6 +459,11 @@ return \@config_file; } + # This is to avoid a '"Config::Std::Hash::DEMOLISH" used only once' + # warning from Class::Std::DESTROY. + sub DEMOLISH { + } + } On Sat, 2010-04-24 at 11:48 -0400, Bill Ricker via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=56862 > > > Thank you again, more grist for the mill. > >