title: How can I reverse the bits of an unsigned byte in Perl?
body: <p>For example, the number 178 should convert to the letter "M". </p>
  
  <p>178 is 10110010. </p>
  
  <p>Reversing all of the bits should give 01001101, which is 77 or "M" as a character.
  I taught about using the Reverse function but I don't know how can I use it on an @array.</p>
  
  <pre><code>use strict;
  use warnings 'all';
  
      open(my $fh1, '&lt;', 'sym.dat') or die $!;
      open(my $fh2, '&lt;', 'sym2.txt') or die $!;
      open my $fh_out, '&gt;', 'symout.txt' or die $!;
  
      until ( eof $fh1 or eof $fh2 ) {
  
          my @l1 = map hex, split '', &lt;$fh1&gt;;
          my @l2 = map hex, split '', &lt;$fh2&gt;;
          my $n = @l2 &gt; @l1 ? @l2 : @l1;
  
          my @sum = map {
              no warnings 'uninitialized';
          $l1[$_] + $l2[$_];
      } 0 .. $n-1;
          @sum = map { split //, sprintf '%08X', $_ } @sum;
          print { $fh_out } "reverse @sum\n";
      }
  </code></pre>
  
  <p>I am calculating here the sum of hex values but the question is the same I want to reverse the byte values.</p>