CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [agent] Help with binary file [\r\n] removal: Edit Log

New User

Aug 4, 2008, 8:10 PM

Views: 1217
Re: [agent] Help with binary file [\r\n] removal

I actually got a c program working to do the 0d 0a removal, but for the sake of understanding what went wrong with my code could you explain to me exactly what you did? Because I dont really understand all of it.

What is the ".="? And could you explain "s/(.{2})\r\n/$1/sg;"?
I mainly don't understand the .{2} and the $1.

Well, I transplanted your code and ran it. It didn't work. It made some changes, but for the most part it didn't remove any 0d 0a's.

are you sure your .bin files are true binary files? You have to use a hex editor to see the values because it should just be gibberish in ASCII. Let me know how it goes.

As for why the 0a 0d 0a fails. I think I figured out the logic. $_ reads in a line, so generally a line would consist of 2 byte data and 2 bytes for the carriage return and new line. But if the data contains a 0a, it considers that as the end of the line.

58 0A 0D 0A, the $_ would only read in 58 0A. However, this doesn't explain how that line would result in a 58 0D 0A print out. Anyone have any insights?

Like I said on my last post, when I ignore what the values of the bytes are and I just use a counter to print out the first two of afour byte sequence I still see the same error.
58 0A 0D 0A -> 58 0D 0A

PS. and I wouldn't laugh. I've spent 3,4 days trying to figure out this problem lol.

(This post was edited by acchao on Aug 4, 2008, 8:11 PM)

Edit Log:
Post edited by acchao (New User) on Aug 4, 2008, 8:11 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives