Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I would like to see a detailed example of the exact situation.
The reason is that I'm not sure exactly what the OP has in this binary file.
See MAC address wiki for gory details

One common form of human readable text is like: 01:23:45:67:89:AB. In a binary form, that is 6, eight bit bytes (2 hex digits each) or 48 bits or 3, 16 bit unsigned integers. If that human form is stored as a string for easy output to humans, that's 17 bytes of ASCII plus probably a trailing zero. A binary file would typically just store the 48 bits (not a string).

You can use regex to replace one binary string with another binary string. However, I am not sure that is best here because we have almost no application details. I suspect that more code than just one regex will be required for a good UI - could be wrong about that - perhaps depends upon what is meant by "good UI"! There are also other possibilities in the menagerie of Perl options.

I hope the OP can show at least a partial hex dump of the file and then explain what he wants to replace with what.
And comment about potential CRC characters is spot on- probably don't exist, but they might.

I would be curious to know a bit higher level of the app like why a low level binary edit is needed?


In reply to Re: search and replace (in-place) strings in binary by Marshall
in thread search and replace (in-place) strings in binary by Laguna

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 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?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-26 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found