title: Converting hex to binary in Perl
body: <p>I want to convert the hex values lying in $1, $2, $3, and $4 to binary and save in an array. I know $1 is only a string, so I tried to convert it to hex before converting to binary, but it doesn't work... Here's my code:</p>
  
  <pre><code>#! usr/bin/perl
  use warnings;
  use strict;
  
  while(&lt;&gt;)
  {
      if(/SIB_DBG/)
      {
          if(/TTRB:\s*([\da-f]+)\s([\da-f]+)\s([\da-f]+)\s([\da-f]+)/ ||
             /ETRB:\s*([\da-f]+)\s([\da-f]+)\s([\da-f]+)\s([\da-f]+)/ ||
             /Command\sETRB\s*([\da-f]+)\s([\da-f]+)\s([\da-f]+)\s([\da-f]+)/ )
          {
              my $one = $1;
              my $two = $2;
              my $three = $3;
              my $four = $4;
              print "$_ $one $two $three $four\n";
              printf("binary :%b\n",$four);
          }
      }
  }
  </code></pre>
  
  <p>My input logfile is like</p>
  
  <pre><code>Aug 31 15:25:53 usb3 kernel: [   78.812034] SIB_DBG TTRB:01000680 00080000 00000008 00030840, PTR: ffff88005ff8b800
  Aug 31 15:25:53 usb3 kernel: [   78.815428] SIB_DBG ETRB: 5ff8b850 00000000 01000000 01018001
  </code></pre>
  
  <p>Also I get an error saying in some of the lines..</p>
  
  <blockquote>
    <p>Argument "f8891" isn't numeric in printf at script.plx line 21, &lt;> line 6.</p>
  </blockquote>