title: Converting ASCII TEXT to Binary
body: <p>I have to convert an ASCII file to Binary. The ASCII file contains a twelve digit hex number in ASCII format. For an input string of 123456789ABC,  I need a six byte output of 0x12\0x34\0x56\0x78\0x9a\0xbc.  Here is the solution that worked. Thanks for the help.</p>
  
  <pre><code>my $filename = 'Hub_Device_ID.txt';
  my $outfile= 'Hub_Device_ID.bin';
  open(my $fh, '&lt;:encoding(UTF-8)', $filename)
           or die "Could not open file '$filename' $!";
  open(my $of, '&gt;:raw', $outfile)
           or die "Could not open file '$outfile' $!";
    binmode($of);
  
    while (my $row = &lt;$fh&gt;){
  
      chomp $row;
      print "Chomped row\n";
      print $row, "\n";
  
  
      my $bytes = pack 'H*', $row;
      print $bytes, "\n";
      print $of $bytes;
  
  
      close $of;
      close $fh;
  
      print "Done\n";
  </code></pre>
  
  <p>}</p>