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: [acchao] Help with binary file [\r\n] removal: Edit Log


Aug 4, 2008, 8:38 PM

Views: 1294
Re: [acchao] Help with binary file [\r\n] removal

hmm that's weird but on my system it works fine, i'd tested it again
either with mine and your input data and it seems to generate proper
results. I've used the hex editor to generate the files ;)

".=" concatenate value of left operand with right operand, that means
if you have $a scalar with string value "ABBA", and you make statement
like $a .= " ROCKS", you'll get "ABBA ROCKS" in $a ;)


(.{2}) matches any two characters (except newline)
$1 represents result of match in first parentheses
so (.{2})\r\n will give you match like "X X 0x0D 0x0A" where X is any value except newline.
/g means global matching as you already know
/s forces to treat the string as single line (it will allow "." to match newline)

all this means that we try to match "X X 0x0D 0x 0A" string and put only the "X X" characters on it's place globally.

to see how while loop read lines try:

while (<INPUT>) {
print OUTPUT $_;
print OUTPUT "0000000000000000000";

And look into the output file you'll get each line separated by "00000000000" string;

Anyway i have no idea why this code doesn't work for you. Can you
post the output you get from my and your input files? Then maybe we'll
find out what's going on :)


(This post was edited by agent on Aug 4, 2008, 8:41 PM)

Edit Log:
Post edited by agent (Novice) on Aug 4, 2008, 8:41 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