title: How do I compare packed values in Perl?
body: <p>I want to use the <a href="http://perldoc.perl.org/functions/pack.html" rel="nofollow noreferrer">pack()</a> function in Perl to encode some data. Then I want to compare my packed structure to another packed structure. I want this compare to be on the byte values of this packed structure.</p>
  
  <p>According to the documentation, <a href="http://perldoc.perl.org/perlop.html" rel="nofollow noreferrer">cmp</a> uses the current locale to determine how to compare strings. But I don't want any intelligence applied to the comparison. I want whatever is closest to a memcmp(). Obviously I cannot use <code>&lt;=></code> for comparing my packed objects as they are not numbers.</p>
  
  <p>What is the best way to compare packed strings in Perl?</p>
  
  <p>Sidenote: I have been reading <a href="http://www.sysarch.com/Perl/sort_paper.html" rel="nofollow noreferrer">this article on efficient sorting in Perl</a> which notes that the plain sort function uses a memcmp-like algorithm for comparing structures. I'm wondering how to achieve such a comparison without having to use sort.</p>