qm mtunnel: add write helper

reduce code duplication.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2017-08-04 14:54:02 +02:00 committed by Wolfgang Bumiller
parent 58cbe63901
commit 79c9e07933

View File

@ -265,11 +265,15 @@ __PACKAGE__->register_method ({
return undef; return undef;
} }
print "tunnel online\n"; my $tunnel_write = sub {
*STDOUT->flush(); my $text = shift;
chomp $text;
print "$text\n";
*STDOUT->flush();
};
print "ver 1\n"; $tunnel_write->("tunnel online");
*STDOUT->flush(); $tunnel_write->("ver 1");
while (my $line = <>) { while (my $line = <>) {
chomp $line; chomp $line;