THRIFT-554: Perl improper namespace check for exception handling and writeMessageEnd missing on processor calls

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@799484 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/perl/lib/Thrift/MemoryBuffer.pm b/lib/perl/lib/Thrift/MemoryBuffer.pm
index 32f1442..0b28687 100644
--- a/lib/perl/lib/Thrift/MemoryBuffer.pm
+++ b/lib/perl/lib/Thrift/MemoryBuffer.pm
@@ -109,6 +109,26 @@
     return $ret;
 }
 
+sub readAll
+{
+    my $self = shift;
+    my $len  = shift;
+
+    my $avail = ($self->{wPos} - $self->{rPos});
+    if ($avail < $len) {
+        die new TTransportException("Attempt to readAll($len) found only $avail available");
+    }
+
+    my $data = '';
+    my $got = 0;
+
+    while (($got = length($data)) < $len) {
+        $data .= $self->read($len - $got);
+    }
+
+    return $data;
+}
+
 sub write
 {
     my $self = shift;