in reply to Re^3: Config::Std to lexial in BEGIN { } throws warning?
in thread Config::Std to lexical in BEGIN { } throws warning?

Oh, the original code does what I want it to do already. Unfortunately the warning pops up. Your version circumvents the warning, but in a way that is not helpful to me, because it cannot be applied to the real code. A little less compact version of the actual code would be:

package Get::Me::My::Config; use Config::Std; sub get_config { read_config _file_name() => my %config; return \%config; } package Database::Stuff; use base q(Rose::DB); use Get::Me::My::Config; sub init_db { my $db_conf = Get::Me::My::Config->get_config->{db_conf}; return _create_db_from($db_conf); }
Something like this. Now to apply your changes, I would need to change the lexical into a package global, which simply is not what I intended for this variable to be at this place.

Replies are listed 'Best First'.
Re^5: Config::Std to lexial in BEGIN { } throws warning?
by MidLifeXis (Monsignor) on Feb 23, 2010 at 18:29 UTC

    Three different posts, at least two slightly different questions (with different solutions).

    Could you please post code, that when run, actually exhibits the full and complete problem that you are seeing. Also, please attach the actual error / warning message that is generated. An actual, fully working demo that reproduces the problem will help greatly.

    Input data (a configuration file), output data (the warnings or errors thrown), code that generates the output data from the input data, and what you actually expect the output data to look like would be most helpful.

    Or, you can keep spoon feeding us information until we accidentally hit upon a solution (or something that looks like a solution).

    Perhaps I am just foggy in the head today.

    It is said that "only perl can parse Perl." I don't even come close until my 3rd cup of coffee. --MidLifeXis

      My apologies, if I didn't get my point across. I did not want a solution for my program, which is why I intentionally posted a minimal proof of concept.

      The original snippet is working and demonstrates what problem I have, that reading a config file, which is no problem normally, generates a warning when forced to execute in BEGIN. Input data (apart from a file that is recognized as a config file by Config::Std), output data does not exist.

      Also I do not want to fix anything, I want to understand why a 'once' warning is triggered in this special case, where in my intuition it should not be triggered.