Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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 ( [id://505348]=note: print w/replies, xml ) Need Help??


in reply to Re^2: 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

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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found