I'm stumped on how to read from a filehandle, where I don't know how many
lines are waiting for me.

Consider this:
mickey> telnet a.mx.example.com 25
Trying 10.0.0.1...
Connected to a.mx.example.com.
Escape character is '^]'.
220-a.mx.example.com ESMTP
220-  EXAMPLE.COM does not authorize the use of its proprietary computers
220-  and computer networks to accept, transmit, or distribute unsolicited
220   bulk e-mail sent from the internet.

I want to save the entire banner, and want to start talking to the smtp
server.  I can not assume the banner is a single line, and I cannot assume
how many lines the banner will be.

on the standard that the last line of the response from a SMTP server has a
space after the code (instead of a dash), using IO::Socket, i've tried
if($sock){
   my $banner;
   while(<$sock>){
      if(/^220\s/){
         chomp;
         $banner .= $_;
         last;
      }else{
         $banner .= $_;
      }
   }
   print "banner is: $banner\n";
}

but that is only a hack for a multi-line SMTP banner.

Is there a way to tell if i have data in <$sock> waiting for me, without
actually reading from the file handle (which could cause it to wait for
input) ?

I've looked at Net::SMTP, but see that it incorrectly assumes only the first
line is the banner.

Note that I'm not looking for a solution for only SMTP (where the /200\s/
give me a way to cheat), but a solution to the problem as a whole.


Jeremy Kister
http://jeremy.kister.net/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to