Hi All, I'm SERIOUSLY starting to cry here :-( It's been over a month since I started this thread, and it's pretty much been close to a year of me battling to get this right with perl, and yes - still not there...
Running under Net::Server, I have: sub process_request { while (<STDIN>) { $_ =~ s/\r?\n$//; # Remove any instance of \r or \n from the end of the received line $_ =~ s/\t//; # Remove any instance of \t from the received line $_ =~ s/[^[:ascii:]]//g; my @Command = split(/\ /, $_); switch($Command['0']) { case m/^\bPOST\b/i { print $sock "340 Ok, send message\r\n"; my $filename = '/tmp/test.txt'; open(OUTFILE, ">", $filename); binmode(OUTFILE); binmode(STDIN); my $size=0; while (read(*STDIN, local $_, 4)) { $self->log(0,Dumper($_)); print OUTFILE $_; $size=$size+length($_); if ($_ =~ /^\.\r\n$/) { last; } } close(OUTFILE); print "240 article received\r\n"; $self->log(0,"received: " . $size); } } } } } 1) From the client, I can confirm via Wireshark, all data has been transmitted (correctly, and successfully), 2) On the server, I can confirm via tcpdump, all the data has been received (correctly, and successfully), 3) In perl, I can confirm the entire message has been received in sequence (whether it's correct or not, I do not know), Certain messages that are sent, decodes correctly (a manual decode of the file that has been written. Other messages that are sent, does not decode correctly (but the data has been transmitted and received correctly). I am able to reproduce, and have data sets of data that works, and data that doesn't work. The problem is that after the file is saved to disk, certain files can decode successfully, whilst others, does not decode correctly. Can someone *PLEASE* just help me to get this sorted out? I am even willing to go off list and pay someone to fix this for me. It's now a serious, serious issue that I need to get resolved asap, and more than likely either something very trivial that I'm overlooking, or a bug somewhere in perl / Net::Server. Yes, this is still yEnc related binary data... And a gazillion things has been tried already (a lot coming from this mailing list). I fail (really, I do), to see why SOME yEnc messages that is saved decodes correctly, and others does not. It's precisely the same code.... The only thing that I can think of is that there are certain characters in some messages that something doesn't like, which IMHO means something is manipulating / changing the data is some way or form... The above code really is simple, there's no changing of data there.... -- Chris. -----Original Message----- From: Brandon McCaig [mailto:bamcc...@gmail.com] Sent: Wednesday, August 12, 2015 8:00 PM To: Chris Knipe <sav...@savage.za.org> Cc: beginners@perl.org Subject: Re: reading from socket On Wed, Aug 12, 2015 at 12:40:29AM +0200, Chris Knipe wrote: > On Wed, Aug 12, 2015 at 12:16 AM, Chris Knipe <sav...@savage.za.org> wrote: > Looking at Data::Dumper - it actually looks like latin1 to me > *seriously > confused* > > $VAR1 = > "L\\xAF\\xF3\\xDDWJL\\x94\\xEB\\xB2\\xF8\\xE1\\xACZ\\x89Ul;\\xB7\\xD > E}1 > '\\xCA\\xC2\\xE3uZ\\xFF7\\xD2=}\\xA8q:;\@,%:_\x{286}-\\xD8\\xF8\\xF > 9E\x{2c1}5\\xD6j+Z?\\xA6\\x9F\\xEC7\\xEC\\xBB4'CNld\\xBE\\xE6=J\ > \xFDL\x{7d4}\\xF9nOz(w\\x83\\xEA\\xD6UHi\\xD5p+\\xBFa\\xADvG\\xD4*a\\ > xEA\\xBBC\\xD0\x{9631}=J\\x96 > \\xFD&\\xF9M\\\\xD\\x89g\\x9EA\\xBD5\\xB4R\\xA0\\xE5sp\\xF3\\xD2x\\x84 > \xEC\\x92y\\x91\\\x{7c1}\\xB1\\xA1\\x9C\\xB73BE\\xA9)\\xCAf\\xC8\\xE > E+\\xA1b\\x8E\\xFCM!\@\\xBE^\\xB5d"; This snippet of data looks like what I perceive the yEncoding to be. If this is the beginning of the message then perhaps the entire stream *is* yEncoded? In that case, decoding the yEnc before processing may be helpful. I don't know what protocol this is... I don't see anything in there that could be mistaken for \r or \n, though I'm not sure how yEnc works. How did you modify the loop to log this? Can you show us the updated program? > And yes - there's numerous characters in the the above that actually > didn't even make it to the email... > http://www.savage.za.org/webpics/perl-encode.png I don't remember mention of an E-mail before. What relationship does that E-mail message have to this program? Note also that you appear to be sending HTML E-mails (see the Internet for why that's evil), which could also potentially mean that what I'm reading in plain text isn't exactly what you intended to send... It all depends on your MUA. You may gain some comfort knowing what you send is what you want to send by switching to plain-text E-mails. Regards, -- Brandon McCaig <bamcc...@gmail.com> <bamcc...@castopulence.org> Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/