my $maxMsgCodeLength = 15; my $ip= 192.168.106.60; my $port= 9000; sub pStartBEMsg { my ($ip, $port) = @_; my $msgCode = "StartBE"; $msgCode = $msgCode.(" " x ($maxMsgCodeLength-length($msgCode))); my $msg = pack("a".$maxMsgCodeLength."ia*",$msgCode, $port, $ip); return $msg; }