Subject: | Unable to turn off dump_log |
Date: | Wed, 4 Apr 2012 13:28:52 -0400 |
To: | "bug-Net-Telnet [...] rt.cpan.org" <bug-Net-Telnet [...] rt.cpan.org> |
From: | Dave Wolaver <dave.wolaver [...] nagra.com> |
Hello,
The Net::Telnet module has been incredibly useful for me and has been rock solid. Thanks for the EXCELLENT work in developing and supporting it.
I believe I have encountered a small bug in dump_log. I am continually calling 'cmd' and expecting a response from a device. When the device does not respond as expected (a low percentage of the time), I am using dump_log to investigate the failures. So, prior to calling 'cmd' I call dump_log as below.
my ($debug_log_fn, $debug_log_fh);
open($debug_log_fh, '>', $debug_log_fn);
$self->{'OBJ_TELNET'}->dump_log($debug_log_fh);
After the call to 'cmd', I close the dump file and delete it if the command was successful (ie. I don't need to see that dump).
$self->{'OBJ_TELNET'}->dump_log('');
close($debug_log_fh);
unlink($debug_log_fn) or die "Could not delete file $debug_log_fn! $!\n";
Everything seems to work fine except that I get errors.
print() on closed filehandle $debug_log_fh at C:/Perl64/lib/Net/Telnet.pm line 2456, <$parent> line 5 (#1) (W closed) The filehandle you're printing on got itself closed sometime before now. Check your control flow.
In the function dump_log, it appears as though passing the empty string '' does not set the hash entry $s->{dumplog} to false which leads to the errors. I can work around the problem by commenting out the 'or return' in dump_log.
I believe the same bug may also be in 'input_log' but I have not verified. One other point... the reason I am passing a filehandle is because I was unable to delete the file when calling 'dump_log' with a filename. This is most likely because the filehandle is not closed when calling dump_log with the empty string. It would be nice to handle this case as well.
Of course, there is always the possibility that my analysis may not be correct, or I have made a mistake on my side. Thanks for your attention and support.
Best regards,
Dave
Perl Dist: Active Perl 5.12.2 Build 1203 (64 bit)
Perl Version: 5.12.2
OS: Windows 7 - 64 bit