$in .= "new data\n"; pump $handle until $$out =~ /data arrived:/; # note the dereferencing - $$out print $$out;