tags:

views:

52

answers:

1

Hi All,

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.

+7  A: 

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' );
Alan Haggai Alavi
Or simply `$message_array = pack "(A*)*", map { q/$_/ } @ul_dcch_message;`
Zaid