使用“pack”发送数组时出现问题Perl 中的函数

发布于 2024-09-27 17:30:25 字数 442 浏览 0 评论 0原文

我正在使用 pack 函数将列表的内容发送到套接字。代码如下。

$message_array = pack ("(A*)*", @ul_dcch_message);

列表内容是

@ul_dcch_message = (101101012411011, "emergency", 25, "simple");

这段代码发送列表中包含的所有字符串和数字。但是,如果列表中的数字超过 15 位,我会得到这样的结果,

 1.01101012411011e+16emergency25simple

我的要求是,我想“打包”数字和字符串,数字将超过 15 位或更多。

有什么办法可以做到吗??还有其他一些模板可以做到这一点吗?

任何帮助表示赞赏。

I am using pack function to send contents of a list to a socket. Code is given below.

$message_array = pack ("(A*)*", @ul_dcch_message);

The list contents are

@ul_dcch_message = (101101012411011, "emergency", 25, "simple");

This piece of code sends all the strings and numbers contained in the list. But if the numbers present in the list exceeds 15 digits, i am getting some thing like this,

 1.01101012411011e+16emergency25simple

My requirement is, I want to 'pack' numbers as well as strings, numbers will exceed 15 digits or more.

Is there any way to do it ?? Is there some other templates to do this ??.

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此岸叶落 2024-10-04 17:30:25

引用该数字,以便 pack 可以将其解释为字符串,而不是用指数表示法表示的数字。

@ul_dcch_message = ( '101101012411011', 'emergency', '25', 'simple' );

Quote the number so that pack could interpret it as a string of characters rather than a number represented in exponential notation.

@ul_dcch_message = ( '101101012411011', 'emergency', '25', 'simple' );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文