I had a script that was plaguing me with the following error:
Can't call method "FETCH" on an undefined value at
C:/Perl/site/lib/Win32/TieRegistry.pm line 1487 during global
destruction.
Searching with Google and in the ASPN archives, I found questions but no
answers that applied to me.
I did discover a minimal script to reproduce the message which makes it
obvious what was causing it in my case.
[code]
#!/usr/bin/perl
use Local::TeeOutput;
use Win32::TieRegistry ( Delimiter=>"/", ArrayValues=>0 );
openTee(*STDERR, *STDERR, ">output.log");
$SoftwareKey = $Registry->{'LMachine/SOFTWARE/'};
exit;
[/code]
I had an openTee that redirected STDERR and if the program died before
completion due to some other error, the closeTee statement did not get
called.
I could have just stuck closeTee statements wherever the script might
exit, but that would be too easy.
Instead, I wanted to know why the error was displaying at all, even if I
removed '-w' from the shebang and replaced it with a '-X' (disable all
warnings).
I found a work-around in the perlfunc document under 'exit'.
[quote]
The exit() function does not always exit immediately. It calls any
defined END routines first, but these END routines may not themselves
abort the exit. Likewise any object destructors that need to be called
are called before the real exit. If this is a problem, you can call
POSIX:_exit($status) to avoid END and destructor processing. See the
perlmod manpage for details.
[/quote]
So to revise my code chunk...
[code]
#!/usr/bin/perl
use Local::TeeOutput;
use POSIX;
use Win32::TieRegistry ( Delimiter=>"/", ArrayValues=>0 );
openTee(*STDERR, *STDERR, ">output.log");
$SoftwareKey = $Registry->{'LMachine/SOFTWARE/'};
POSIX:_exit{$status};
[/code]
This produces no spurious errors at all.
I hope this can help someone else out.
I spent a few hours banging my head against the wall trying to get it to
go away.
-Jason
PS - I apologize in advance for the legal disclaimer at the bottom of my
email message. This is tacked on by our SMTP gateway and I have no
control over it.
--
------------------------------------------------------------------------------
Confidentiality notice:
This e-mail message, including any attachments, may contain legally privileged and/or
confidential
information. If you are not the intended recipient(s), or the employee or agent
responsible for delivery
of this message to the intended recipient(s), you are hereby notified that any
dissemination,
distribution, or copying of this e-mail message is strictly prohibited. If you have
received this message
in error, please immediately notify the sender and delete this e-mail message from
your computer.
==============================================================================
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs