Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: how to read in a binary file and convert it to ascii output

by JFarr (Sexton)
on Nov 03, 2005 at 13:35 UTC ( [id://505329]=note: print w/replies, xml ) Need Help??


in reply to Re: how to read in a binary file and convert it to ascii output
in thread how to read in a binary file and convert it to ascii output

Thank all of you for the help. That dumped out the file in hex, now I can parse through and get the ascii. Thanks again
  • Comment on Re^2: how to read in a binary file and convert it to ascii output

Replies are listed 'Best First'.
Re^3: how to read in a binary file and convert it to ascii output
by graff (Chancellor) on Nov 03, 2005 at 14:12 UTC
    now I can parse through and get the ascii

    That makes it sound like you want to read through a file that contains both "printable" and "non-printable" byte values, and display only the printable (ascii) stuff. On unix, there is a command called "strings" to do exactly that.

    A perl implementation would be something like this (assuming the file is not too big to hold in memory):

    $_ = do { local $/; <> }; s/[^\t\n\r -~]+/\n/g; print;
    You could tweak that to print only strings that are some minimum length, etc. Anything else you know about the binary file (e.g. strings of interest are all terminated by null bytes, or something like that) could be used to good effect in making sure you only print the interesting parts.
Re^3: how to read in a binary file and convert it to ascii output
by derby (Abbot) on Nov 03, 2005 at 13:57 UTC

    It sounds like you're looking for the strings command.

    -derby

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://505329]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-23 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found