Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Just two quick thoughts for now: open the file with the mode '<:raw' (or binmode the handle after opening but before reading), and add the /aa regex modifier (perlre) to your regexen.

Update: I didn't have enough time earlier to explain why I made these two suggestions, so let me do that now. First, note that on Windows, the :crlf PerlIO layer is active by default, translating CRLFs to LFs, which isn't good for binary data. Also, opens without explicit layers can be affected by the open pragma. Second, if you were to open the file with an encoding layer, under Unicode matching rules (see /u in perlre), \d matches any Unicode digits (see "Digits" in perlrecharclass).

Update 2: Typo fix


In reply to Re: Calculated position incorrect when using regex in text file that also contains binary info (updated) by haukex
in thread Calculated position incorrect when using regex in text file that also contains binary info by geertvc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2021-10-18 05:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (72 votes). Check out past polls.

    Notices?