Heya, Monks. When I began using the Net::Telnet module to write a MU* bot, I used the following procedure: I created a while loop which on every iteration checked for the previous line, like this:
$line = $telnet->getline(Timeout=>1000000);

I used the long Timeout obviously so that it wouldn't time out. The problem came when I added another connection. Now, it won't getline from one of the connections until it has recieved a new line from the other. Here's the entire program, currently:

#Use the telnet module use Net::Telnet; #Variables my $dbl; my $rwl; my $person; #And now, define all the servers we're going to use: $darkblade = new Net::Telnet (Timeout=>10, Errmode=>'die', Port=>7575) +; $redwall = new Net::Telnet (Timeout=>10, Errmode=>'die', Port=>4203); #Here we actually connect: print "Now connected to Darkblade...\n"; $darkblade->open('darkblade.2y.net'); sleep(2); print "Now logged into Darkblade as Boteille.\n"; $darkblade->print('connect boteille abc123'); print "Now connected to Redwall...\n"; $redwall->open('redwall.muck.limitless.org'); sleep(2); print "Now logged into Redwall as Scava.\n"; $redwall->print('connect scava abc123'); #Now start a while() loop to listen for input... BREAK: while(1) { #this is the variable new lines in Darkblade will be stored in: $dbl = $darkblade->getline(Timeout=>1000000); #And the same sort of thing for Redwall... $rwl = $redwall->getline(Timeout=>1000000); #Avoid idle boots in Darkblade: if ($dbl =~ 'The rains are approaching...') { $darkblade->print('dshf'); } if ($dbl =~ '2 mins before auto idleboot.') { $darkblade->print('dshf'); } #And also in Redwall... if ($rwl =~ 'IDLE-BOOT: You will be dropped in 5 minutes.') { $redwall->print('dshf'); } #And now we get to the first use... if someone asks for help if($dbl =~ /pages, "help"/) { ($person) = $dbl =~ /^(\w+)/; $darkblade->print("page $person=Boteille currently supports..."); $darkblade->print("page $person=-- This help page"); } if($rwl =~ /pages, "help"/) { ($person) = $rwl =~ /^(\w+)/; $redwall->print("page $person=Scava currently supports..."); $redwall->print("page $person=-- This help page"); } }


Is there a more efficient way of doing this, or a way to bypass this problem?

In reply to Net::Telnet problems by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.