Subject: | 'used only once' warning from DESTROY |
The DESTROY sub can trigger a 'used only once' warning if it is executed
during the compile phase. For example, some uses of Config::Std cause a
'used only once' warning to be produced for Config::Std::Hash::DEMOLISH.
While it might be a rare case that produces the warning, it can be
avoided by disabling warnings 'once' in sub DESTROY.
$ diff -u Class/Std.pm /usr/share/perl5/Class/Std.pm
--- Class/Std.pm 2010-04-26 21:50:09.000000000 +1200
+++ /usr/share/perl5/Class/Std.pm 2010-04-26 21:49:22.000000000 +1200
@@ -520,6 +520,7 @@
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};
}