perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:

I have the following:
package Cmds; #{{{ use Readonly; sub RO(\[$@%]@){goto &Readonly}; use File::SearchPath qw /searchpath/; RO our $sig => "%%"; #improbable filename prefix RO our $Dflt_Path => "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin +"; sub skey($) {$sig.$_[0]} our %Global_Cache = ( # Global cache fo +r non-OO use skey("asis") => 0, skey("Firstcap") => 1, skey("prefix_ln") => 0, skey("post_ln") => 0, skey("SAFE_PATH") => $Dflt_Path, skey("PATH") => $Dflt_Path, skey("path_safe") => 1, skey("imp_init") => 1, #global alread +y is initialized! ;-") );
and am getting the following warnings from this file:
Use of uninitialized value $Cmds::sig in concatenation (.) or string a +t ./shaper.pl line 58. Use of uninitialized value $Cmds::sig in concatenation (.) or string a +t ./shaper.pl line 58. Use of uninitialized value $Cmds::sig in concatenation (.) or string a +t ./shaper.pl line 58. Use of uninitialized value $Cmds::sig in concatenation (.) or string a +t ./shaper.pl line 58. Error extracting directories from environment. No defined values suppl +ied. Internal programming error at ./shaper.pl line 76 Compilation failed in require at /home/law/bin/lib/Network/Interface.p +m line 6. BEGIN failed--compilation aborted at /home/law/bin/lib/Network/Interfa +ce.pm line 6. Compilation failed in require at ./shaper.pl line 226. BEGIN failed--compilation aborted at ./shaper.pl line 226.
line 58 is the 1 line routine in the listing that defines sub skey (concatenating a constant with any param to form a keyname that I thought I would be likely to use as part of a filename...;-))... I had "\0x00" in the beginning of the key, figuring that'd be impossible for use in a Unix file name (and didn't think it should be a problem as a hash key), but thought that might be causing this issue. so replaced it with a dup of the 2nd char).

So why is it ignoring the define of '$sig' immediately above it? and claiming it is "undefined"

I also tried"$sig" as a package as 'my'...nada...(same error)

So...doesn't like my/our, ?... um?...

What am I missing?

Replies are listed 'Best First'.
Re: Values initialized at compile time appear not to be getting initialized..?
by Corion (Patriarch) on Nov 20, 2011 at 10:32 UTC

    I presume that the problem is within Readonly, as reducing your program to a simple case without Readonly makes the problem go away:

    package Cmds; use strict; use warnings; sub RO(\[$@%]@) { warn "Assigning $_[0] <= $_[1]"; ${$_[0]} = $_[1] }; RO our $sig => "&#65285;&#65285;"; #improbable filename prefix warn "\$sig lives at " . \$sig; sub skey($) {$sig.$_[0]} our %Global_Cache = ( skey("asis") => 0, ); package main; print "Done\n";

    I recommend you post actual, self-contained, working code.

    As an aside, the string "&#65285;&#65285;" likely does not do what you think it does, unless you are outputting HTML.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Values initialized at compile time appear not to be getting initialized..?
by ikegami (Patriarch) on Nov 20, 2011 at 18:48 UTC

    I get no such error. Even if I turn on warnings. I don't think you ran the code you posted.

    Why do you mention "at compile-time" in the subject? You didn't show anything of the kind.