while (1) { my $ret= print $ret; if ($ret=~/^OK/ || $ret=~/^ERROR/) { last} }