about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>2000-01-31 07:52:34 +0000
committerGraham Barr <gbarr@pobox.com>2000-01-31 07:52:34 +0000
commitbe5f504ca7587f1fe5e760d50b79fceeaf3ef79c (patch)
tree32c59b556e9556157671ead5f38aad8215b9b6ad
parent3dd5b5facc0757628b5c8f7131eed5e9029dd56f (diff)
downloadperl-libnet-be5f504ca7587f1fe5e760d50b79fceeaf3ef79c.tar.gz
Net::Cmd
- Fixed bug in getline returning an empty line
- Added optional filehandle argument to read_until_dot.

Net::POP3
- get now takes an optional filehandle argument, if given the
  message is sent to the handle.

-rw-r--r--Net/Cmd.pm16
-rw-r--r--Net/POP3.pm16
2 files changed, 20 insertions, 12 deletions
diff --git a/Net/Cmd.pm b/Net/Cmd.pm
index e6870e7..22b8d48 100644
--- a/Net/Cmd.pm
+++ b/Net/Cmd.pm
@@ -13,7 +13,7 @@ use strict;
 use vars qw(@ISA @EXPORT $VERSION);
 use Carp;
 
-$VERSION = "2.17";
+$VERSION = "2.18";
 @ISA     = qw(Exporter);
 @EXPORT  = qw(CMD_INFO CMD_OK CMD_MORE CMD_REJECT CMD_ERROR CMD_PENDING);
 
@@ -241,9 +241,7 @@ sub getline
 
      my @buf = split(/\015?\012/, $buf, -1);        ## break into lines
 
-     $partial = length($buf) == 0 || substr($buf, -1, 1) eq "\012"
-                ? ''
-                  : pop(@buf);
+     $partial = pop @buf;
 
      push(@{${*$cmd}{'net_cmd_lines'}}, map { "$_\n" } @buf);
 
@@ -312,6 +310,7 @@ sub response
 sub read_until_dot
 {
  my $cmd = shift;
+ my $fh  = shift;
  my $arr = [];
 
  while(1)
@@ -325,7 +324,14 @@ sub read_until_dot
 
    $str =~ s/^\.\././o;
 
-   push(@$arr,$str);
+   if (defined $fh)
+    {
+     print $fh $str;
+    }
+   else
+    {
+     push(@$arr,$str);
+    }
   }
 
  $arr;
diff --git a/Net/POP3.pm b/Net/POP3.pm
index f56fa55..64de4c4 100644
--- a/Net/POP3.pm
+++ b/Net/POP3.pm
@@ -13,7 +13,7 @@ use Net::Cmd;
 use Carp;
 use Net::Config;
 
-$VERSION = "2.20"; # $Id: //depot/libnet/Net/POP3.pm#15 $
+$VERSION = "2.21"; # $Id: //depot/libnet/Net/POP3.pm#16 $
 
 @ISA = qw(Net::Cmd IO::Socket::INET);
 
@@ -226,13 +226,13 @@ sub list
 
 sub get
 {
- @_ == 2 or croak 'usage: $pop3->get( MSGNUM )';
+ @_ == 2 or @_ == 3 or croak 'usage: $pop3->get( MSGNUM [, FH ])';
  my $me = shift;
 
  return undef
-    unless $me->_RETR(@_);
+    unless $me->_RETR(shift);
 
- $me->read_until_dot;
+ $me->read_until_dot(@_);
 }
 
 sub delete
@@ -452,10 +452,12 @@ If called without arguments a reference to a hash is returned. The
 keys will be the C<MSGNUM>'s of all undeleted messages and the values will
 be their size in octets.
 
-=item get ( MSGNUM )
+=item get ( MSGNUM [, FH ] )
 
-Get the message C<MSGNUM> from the remote mailbox. Returns a reference to an
-array which contains the lines of text read from the server.
+Get the message C<MSGNUM> from the remote mailbox. If C<FH> is not given
+then get returns a reference to an array which contains the lines of
+text read from the server. If C<FH> is given then the lines returned
+from the server are printed to the filehandle C<FH>.
 
 =item last ()