Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I try to write all of my scripts error free with the -w switch.(which I am rarely succesfull at) Whenever I write something using the Tk module, I get "Use of uninitialized variable at Tk.pm line 350". It does not effect the script at all, but I am curious to how I would stop it. I looked in the Tk.pm source on line 350 and it deals with the variable $Home which stores your $ENV{'HOME'} variable. I try to add $Home=$ENV{'HOME'}; in my source, but no luck still same message.

Replies are listed 'Best First'.
Re: Tk perfection
by mortis (Pilgrim) on Mar 20, 2000 at 05:52 UTC
    One possible solution (other than modifying the Tk module) is to use the technique you're thinking of with the
    $Home = $ENV{'HOME'};
    statement. Keep a few things in mind:

    your $Home will be in your namespace (probably main), while Tk's is in the Tk namespace, so you'd have to do something like this:
    $Tk::Home = $ENV{'HOME'};
    your code (probably) won't get executed untill after the Tk module unless you surround it in a BEGIN block, like this:
    BEGIN { $Tk::Home = $ENV{'HOME'}; }
    The best thing to do is probably to do as already suggested, get the newest version of Tk, and fix and submit the patch if necessary.
RE: Tk perfection
by Anonymous Monk on Mar 20, 2000 at 02:48 UTC
    Personally, what I'd do is first make sure that I have the latest version of the Tk module installed. Once I was sure of that I'd look at modifying the Tk module to get it to stop generating the warning. Once I got a working fix I'd send your patch back to the maintainer of the Tk module.