Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Perl Script to Test Telnet Connectivity

by LanX (Saint)
on Nov 08, 2022 at 22:12 UTC ( [id://11148051]=note: print w/replies, xml ) Need Help??


in reply to Perl Script to Test Telnet Connectivity

Welcome to the monastery! :)

DISCLAIMER: I never used that module!

But it's obvious that your use of exists on scalar values is weird.

from this documentation of Net::Telnet ...

> When mode is "return" then the method generating the error places an error message in the object and returns an undefined value in a scalar context and an empty list in list context. The error message may be obtained using errmsg().

... I suppose you want to used defined instead.

FWIW: Another way is to keep the error-mode "die" and to catch the exception with a surrounding block eval (that's a try-catch in newest Perl).

Like that you'd get better diagnostics what went wrong.

Hope this helps! :)

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re: Perl Script to Test Telnet Connectivity

Replies are listed 'Best First'.
Re^2: Perl Script to Test Telnet Connectivity
by redapplesonly (Sexton) on Nov 09, 2022 at 18:25 UTC

    It did help, and thanks Rolf. So the defined keyword is a new one for me, but it made all the difference here. This is an awesome site...! Thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148051]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-18 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found