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.

10.3. Reduce timeout

- Reduce the timeout
- Wait for a string we know will show up
- After seeing Username: we should type in 'admin', the username

Example 10-2. examples/cli/

use strict;
use warnings;

use Net::Telnet;

my $port = 8000;
my $hostname = 'localhost';

my $telnet = Net::Telnet->new(
                        Port      => $port,
                        Host      => $hostname,
                        Dump_log  => 'dump.log',
                        Input_log => 'input.log',
                        Timeout   => 1,
print "opened\n";

    my ($prematch, $match) = $telnet->waitfor('/Username:.*$/');
    if ($prematch =~ /Welcome/) {
        print "welcome printed\n";

print "after wait\n";

If you are interested in on-site trainings by the author, please contact me directly.