title: Extracting strings from binary file using regex and converting to ASCII -- Using Perl
body: <p>Trying to figure out how to extract a string off characters from a binary file and convert them to ascii. The characters are a barcode, which is preceded by a constant string of text. My thought is to figure out what the HEX pattern is for the string constant string and extract the string based on that, then convert the HEX to ASCII.</p>
  
  <p>Problem is I don't know how get perl to "read" the file, or "see" what it's seeing. Meaning that if the file was a text file, might do something like this - <a href="https://stackoverflow.com/questions/874915/perl-extracting-data-from-text-using-regex">Perl: extracting data from text using regex</a> - but I don't know how to figure out what the binary pattern I'm targeting is; that said, I've posted one view of this data here: <a href="https://stackoverflow.com/questions/5950754/extracting-plaintext-header-from-hex-file-using-perl">Extracting “plaintext” header from HEX file using Perl</a></p>
  
  <p>How do I do this in Perl?</p>