How do I compare packed values in Perl? -


I want to use the function in the furl to encode some data, then I will have another pack I want to compare the structure. I want to compare the byte values ​​of this pack's structure.

According to the document, uses the current locale to compare strings. But I do not want any intelligence to compare. I want that whatever is near a memcmp (), obviously I want to compile my packed object to & lt; => because they are not numbers.

What is the best way to compare pack strings in Perl?

SeedNot: I am reading that uses a memcamp-like algorithm to compare structures in a plain sort function. I am thinking that how to achieve such comparison without having to sort it out.

Normally block and use cmp :

  sub mycmp {no locale; $ _ [0] CMP $ _ [1]; }  

document

lie , take , ge provided Use the code, gt and cmp coded (sort) order specified by the existing code, if the use of locale is effective.

and then

The default behavior is not restored with any location pragma, or until its end For example, for example,

  My ($ one, $ 2) = map pack is running <">  n", $ _) => 1, 2; MacPump ($ one, $ 2); Macamp ($ 2, $ one);  

output

 -1 1 

Comments