Index: /trunk/api/perl/t/100_flush_bug.t
===================================================================
--- /trunk/api/perl/t/100_flush_bug.t (revision 790)
+++ /trunk/api/perl/t/100_flush_bug.t (revision 790)
@@ -0,0 +1,58 @@
+#!/usr/bin/env perl -w
+
+use strict;
+use Test::More;
+use Cache::Memcached;
+use IO::Socket::INET;
+
+my $testaddr = "127.0.0.1:11311";
+my $sock = IO::Socket::INET->new(
+    LocalAddr => $testaddr,
+    Proto     => 'tcp',
+    ReusAddr  => 1,
+);
+
+my @res = (
+    ["OK\r\n", 1],
+    ["ERROR\r\n", 0],
+    ["\r\nERROR\r\n", 0],
+    ["FOO\r\nERROR\r\n", 0],
+    ["FOO\r\nOK\r\nERROR\r\n", 0],
+    ["\r\n\r\nOK\r\n", 0],
+    ["END\r\n", 0],
+);
+
+if ($sock) {
+    plan tests => scalar @res;
+} else {
+    plan skip_all => "cannot bind to $testaddr\n";
+    exit 0;
+}
+close $sock;
+
+
+my $pid = fork;
+die "Cannot fork because: '$!'" unless defined $pid;
+unless ($pid) {
+    my $sock = IO::Socket::INET->new(
+        LocalAddr => $testaddr,
+        Proto     => 'tcp',
+        ReusAddr  => 1,
+        Listen    => 1,
+    ) or die "cannot open $testaddr: $!";
+    my $csock = $sock->accept();
+    while (defined (my $buf = <$csock>)) {
+        my $res = shift @res;
+        print $csock $res->[0];
+    }
+    close $csock;
+    close $sock;
+    exit 0;
+}
+
+my $memd = Cache::Memcached->new({ servers   => [ $testaddr ] });
+
+for (@res) {
+    ($_->[0] =~ s/\W//g);
+    is $memd->flush_all, $_->[1], $_->[0];
+}
Index: /trunk/api/perl/lib/Cache/Memcached.pm
===================================================================
--- /trunk/api/perl/lib/Cache/Memcached.pm (revision 713)
+++ /trunk/api/perl/lib/Cache/Memcached.pm (revision 790)
@@ -784,5 +784,5 @@
         my $sock = $self->sock_to_host($host);
         my @res = $self->run_command($sock, "flush_all\r\n");
-        $success = 0 unless (@res);
+        $success = 0 unless (scalar @res == 1 && (($res[0] || "") eq "OK\r\n"));
     }
 
Index: /trunk/api/perl/ChangeLog
===================================================================
--- /trunk/api/perl/ChangeLog (revision 710)
+++ /trunk/api/perl/ChangeLog (revision 790)
@@ -1,2 +1,5 @@
+	* flush_all now only returns success if there is a proper reply from all
+	  servers - Yann Kerherve <yann@sixapart.com>
+	
 	* 'noreply' support from Tomash Brechko <tomash.brechko@gmail.com>
 
