You are looking at a very old, but free version of the course.
If you are interesed the most recent version, check it out
on the Perl Maven site.
Setting both Dump_log and Input_log in the constructor of Net::Telnet
will allow us to see what is really going on on the connection.
We also add a call to wait for something that is likely won't show up
in the output. Depending on where the demo application (the daemon)
is running you might need to change the $hostname variable.
Example 10-1. examples/cli/cli_01.pl
my $port = 8000;
my $hostname = 'localhost';
my $telnet = Net::Telnet->new(
Port => $port,
Host => $hostname,
Dump_log => 'dump.log',
Input_log => 'input.log',
my ($prematch, $match) = $telnet->waitfor('/not likely to show up/');
print "after wait\n";
Running the script we notice that after printing "opened" it waits
quite a lot of time and it never prints "after wait".
This happend because waitfor was waiting for a string that never
showed up. Hence it gave up waiting after the built-in timeout
period. Once it reached the timeout it called the default errmode()
function which is the "die" function. So the script never reached
the second print() and did not have a chance to print anything.
If you are interested in on-site trainings by the author, please
contact me directly.