From be5f504ca7587f1fe5e760d50b79fceeaf3ef79c Mon Sep 17 00:00:00 2001 From: Graham Barr Date: Mon, 31 Jan 2000 07:52:34 +0000 Subject: 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. --- Net/Cmd.pm | 16 +++++++++++----- Net/POP3.pm | 16 +++++++++------- 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'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 from the remote mailbox. Returns a reference to an -array which contains the lines of text read from the server. +Get the message C from the remote mailbox. If C is not given +then get returns a reference to an array which contains the lines of +text read from the server. If C is given then the lines returned +from the server are printed to the filehandle C. =item last () -- cgit v1.2.3-24-ge0c7