title: When would you use unpack('h*' ...) or pack('h*' ...)?
body: <p>In Perl, <a href="http://perldoc.perl.org/functions/pack.html" rel="noreferrer"><code>pack</code></a> and <a href="http://perldoc.perl.org/functions/unpack.html" rel="noreferrer"><code>unpack</code></a> have two templates for converting bytes to/from hex:</p>
  
  <blockquote>
    <p><code>h</code>&nbsp;&nbsp;&nbsp; A hex string (low nybble first).<br>
    <code>H</code>&nbsp;&nbsp;&nbsp; A hex string (high nybble first).</p>
  </blockquote>
  
  <p>This is best clarified with an example:</p>
  
  <pre><code>use 5.010; # so I can use say
  my $buf = "\x12\x34\x56\x78";
  
  say unpack('H*', $buf); # prints 12345678
  say unpack('h*', $buf); # prints 21436587
  </code></pre>
  
  <p>As you can see, <code>H</code> is what people generally mean when they think about converting bytes to/from hexadecimal.  So what's the purpose of <code>h</code>?  Larry must have thought someone might use it, or he wouldn't have bothered to include it.</p>
  
  <p><strong>Can you give a real-world example where you'd actually want to use <code>h</code> instead of <code>H</code> with <code>pack</code> or <code>unpack</code>?</strong>  I'm looking for a specific example; if you know of a machine that organized its bytes like that, what was it, and can you link to some documentation on it?</p>
  
  <p>I can think of examples where you could <em>use</em> <code>h</code>, such as serializing some data when you don't really care what the format is, as long as you can read it back, but <code>H</code> would be just as useful for that.  I'm looking for an example where <code>h</code> is <em>more</em> useful than <code>H</code>.</p>