I ran into this problem while trying to configure RDBO connections on startup by reading a config file. RDBO has a nasty habit of doing a lot of things during compile time, so the essence boils down to:

#!/usr/bin/perl BEGIN { use Config::Std; read_config "main.conf" => my %config; }

...which runs fine (assuming, you've got a valid main.conf), but warns:

Name "Config::Std::Hash::DEMOLISH" used only once: possible typo at /usr/share/perl5/Class/Std.pm line 523.

No problems on execution. It only happens when %config is a lexical though, which I suspect to be part of the problem.

I searched for this, but other than a similar but unrelated warning thrown by LedgerSMB this does not seem to happen to other people. I could just try to make it go away, but I'd rather understand the cause before that.

Any ideas?

Edit: I'll need to clarify.

The main code is nowhere near this snippet. In reality the config is encapsulated into a Moose object that reads the config in its BUILD into an attribute, and will then be instanciated elsewhere, and a long way down the line will be handed to RDBO.

The actual code runs under strict, and the snippet is only for quick reproduction. If you need it even shorter, try:

perl -le 'BEGIN { use Config::Std; read_config "main.conf" => my %config }'

Feel free to add strictures and warnings to your liking, it should not change the outcome. What does change the outcome though is a different perl version. 5.8.8 does not give the warning, 5.10.0 and 5.11.0 do. *sigh*


In reply to Config::Std to lexical in BEGIN { } throws warning? by gorash

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.