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

Good Afternoon Fellow Monk!
I moved my script from WinXP to Win7(64 bit) using Activestate Perl on both machines, installing all the same modules and once completed I ran the script with the following errors. Thanks in advance the step in the right direction to find the solutions.
Errors: Use of uninitialized value $file in open at C:/Perl64/lib/IO/File.pm line 187
Can't use an undefined value as a symbol reference at C:\USER\script.pl line 162
Uncaught exception from user code:
Can't use undefined value as a symbol reference at C:\USER\script.pl line 162 structure::begin() called at C:\USER\script.pl line 154

my $tee = new IO::Tee(\*STDOUT, new IO::File(">>$config::logfile")); Line 154: begin(); Line 162: print $tee colored ("---",$config::menucolor); Line 187 from Perl64/lib/IO/File.pm: open($fh, $file);

My config file is in a config folder. The config folder is located in the same folder as script.pl This script works fine under WinXP not so on Win7. Are there that many differences in code styles?

Replies are listed 'Best First'.
Re: Undefined Value as Symbol reference
by runrig (Abbot) on Mar 07, 2014 at 17:48 UTC
    My first guess is that $config::logfile is not what you think it is. My first suggestion is to make sure it is what you think it is.

    My next suggestion is to check to make sure your file (and tee) open is successful.

      $config::logfile is in reference to the config.pm which is located in the config folder and within the config.pm is a variable called $logfile = "output.txt";

      package config; $logfile = "output.txt"; 1;

      Of course there are other variables in the config.pm that the user can specify to his/her applications. This works fine under WinXP not Win7 for some reason.

        When I say 'make sure...' I mean something like:
        print "LOGFILE: $config::logfile\n";
        And then you can say, "yes, it's what it's supposed to be" (or not). I don't care what it's supposed to be in reference to...just what it actually is. And did I mention "check if your open's are successful" ?
Re: Undefined Value as Symbol reference
by kcott (Archbishop) on Mar 07, 2014 at 20:03 UTC

    G'day PilotinControl,

    Use of indirect object notation is strongly discouraged. I recommend you don't use it. See "perlobj: Invoking Class Methods" for further details.

    The code you've posted, using indirect object notation (twice), appears to have been copied from EXAMPLE code in the IO::Tee documentation. That documentation was written 13 years ago!

    Also, consider using the autodie pragma to check for IO success or failure.

    -- Ken