note
rob_au
This is a good review of [cpan://Net::Telnet] - I was interested in the bug-report and the problem which you found executing code under <code>-w</code> and so decided to do a little digging.<p>
The problem which you encountered can be replicated on ActiveState Perl build 630 with the following line:<p>
<dl><dd><code>
>C:\>perl -MNet::Telnet -w -e "$obj = Net::Telnet->new; $obj->open(Host => '127.0.0.1');"
Argument "" isn't numeric in numeric gt (>) at C:/Perl/site/lib/Net/Telnet.pm line 2569.
</code></dd></dl><p>
The problem lies in the <code>_optimal_blksize</code> method of the [cpan://Net::Telnet|Telnet.pm] module and is not related to ActiveState per se, but the manner by which this method is called from within the <code>new</code> initiation method. The code for the <code>_optimal_blksize</code> method is as follows:<p>
<dl><dd><code>
sub _optimal_blksize {
my ($blksize) = @_;
return $blksize
if defined $blksize and $blksize > 0 and $blksize <= 1_048_576;
8192;
} # end sub _optimal_blksize
</code></dd></dl><p>
This method is called without any parameters from the [cpan://Net::Telnet] <code>new</code> method and as such the variable <code>$blksize</code> will be undefined. This rightly generates the warning in the <code>return $blksize if defined $blksize and ...</code> line. This is expected behaviour under <code>-w</code>.<p>
A straight-forward fix for this problem under <code>-w</code> execution can be applied by adding the line:<p>
<dl><dd><code>
sub _optimal_blksize {
my ($blksize) = @_;
$blksize ||= 0;
return $blksize
if defined $blksize and $blksize > 0 and $blksize <= 1_048_576;
8192;
} # end sub _optimal_blksize
</code></dd></dl><p>
... which can be applied as the following diff patch ...<p>
<dl><dd><code>
2568d2567
< $blksize ||= 0;
</code></dd></dl><p>
As an aside note, I tested and was unable to replicate this warning with similarly versioned copies of [cpan://Net::Telnet] on Perl 5.6.1 on a i686-Linux system. Perhaps there is something more to this or the way by which warnings are generated?
<p> <p>
<tt><font size="-1"></font></tt>
156748
156748