Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
This is a good review of Net::Telnet - I was interested in the bug-report and the problem which you found executing code under -w and so decided to do a little digging.

The problem which you encountered can be replicated on ActiveState Perl build 630 with the following line:

>C:\>perl -MNet::Telnet -w -e "$obj = Net::Telnet->new; $obj->open(Hos +t => '');" Argument "" isn't numeric in numeric gt (>) at C:/Perl/site/lib/Net/Te line 2569.

The problem lies in the _optimal_blksize method of the module and is not related to ActiveState per se, but the manner by which this method is called from within the new initiation method. The code for the _optimal_blksize method is as follows:

sub _optimal_blksize { my ($blksize) = @_; return $blksize if defined $blksize and $blksize > 0 and $blksize <= 1_048_576; 8192; } # end sub _optimal_blksize

This method is called without any parameters from the Net::Telnet new method and as such the variable $blksize will be undefined. This rightly generates the warning in the return $blksize if defined $blksize and ... line. This is expected behaviour under -w.

A straight-forward fix for this problem under -w execution can be applied by adding the line:

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

... which can be applied as the following diff patch ...

2568d2567 < $blksize ||= 0;

As an aside note, I tested and was unable to replicate this warning with similarly versioned copies of 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?


In reply to Re: Net::Telnet by rob_au
in thread Net::Telnet by Rex(Wrecks)

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2023-06-05 13:57 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (25 votes). Check out past polls.