in reply to Re^2: "used only once" warning from Class::Std
in thread "used only once" warning from Class::Std

Because Class::Std starts with
package Class::Std; our $VERSION = '0.011'; use strict; use warnings; use Carp; use Scalar::Util; use overload;
and your module doesn't! Use strict warnings and diagnostics or die

Replies are listed 'Best First'.
Re^4: "used only once" warning from Class::Std
by ig (Vicar) on Apr 25, 2010 at 04:52 UTC

    I wish it were so simple, but I don't think so. In fact, my main program and module both had use strict; and use warnings; originally, as I use them habitually. So much so that initially I had thought the warnings were produced because of them and reported a bug on Config::Std that it was incompatible with use warnings;. It was only later that I realized the warning didn't go away when I removed use strict; and use warnings; from my own code.

    None the less, to test your assertion, I changed the main program to:

    #!/usr/bin/perl use strict; use warnings; use MyClass; my $obj = MyClass->new();

    but still the warning was produced.

    Then I changed the module to:

    package MyClass; use strict; use warnings; use Class::Std; my $hash_ref = {}; bless $hash_ref, 'MyClass'; sub DEMOLISHx { print "demolishing...\n"; } 1;

    And still the warning was produced.

    So, after all, the warning wasn't produced because Class::Std uses strict and warnings and my module doesn't.

    Other ideas?