Senthil kumar
Senthil kumar

Reputation: 1003

Problem with sending an array using 'pack' function in perl

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.

Upvotes: 4

Views: 771

Answers (1)

Alan Haggai Alavi
Alan Haggai Alavi

Reputation: 74252

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' );

Upvotes: 7

Related Questions