my $one = "1234"; my $two = 1234; my $d = pack("nn", $one, $two); # See the size of packed data (it is 4 bytes). print length($d), "\n"; # See that both string and number are packed the same way. print unpack("H*", $d), "\n";