# OK to use blocking calls, the data will be there # don't read past the "DONE", wait for next file event # otherwise this will "hang". my $msg; while (my $line = <$child_fh>) { $msg =. $line; last if $line =~ /^:DONE:\s*$/; } if ($msg !~ /^:MSG:/) {framing error!} do what you need to do... $msg = undef;