开发者

How can I cast UDP streams in Perl?

开发者 https://www.devze.com 2023-01-02 13:19 出处:网络
My Perl script gets a UDP response that is built out of 2 integers + float numbers. The problem is that the UDP stre开发者_开发问答am is one long stream of bytes.

My Perl script gets a UDP response that is built out of 2 integers + float numbers. The problem is that the UDP stre开发者_开发问答am is one long stream of bytes.

How do I cast the stream into parameters using Perl?


You can use unpack or Convert::Binary::C.

For more on pack and unpack see perlpacktut - the Pack Tutorial.

With Convert::Binary::C, you pass in a C struct definition, and then you can easily extract the data members from the struct.

0

精彩评论

暂无评论...
验证码 换一张
取 消