On Thu, Sep 17, 2015 at 10:55:58PM +0200, Chris Knipe wrote: > Hi All, Hello,
> Running under Net::Server, I have: Unfortunately, you seem to be neglecting to give us full programs to test with which requires us to do guess work. The best way to get help is to do your best to reproduce the problem with as little code as possible, and post a *complete* program that we can debug without having to do any extra research or writing ourselves. > sub process_request { > while (<STDIN>) { You should assign the line to a variable instead of using $_. That will protect you against $_ being implicitly overwritten or being overwritten from a distance. > $_ =~ s/\t//; # Remove any instance of \t from the received > line This will only remove the first occurrence of tab in the string. It won't remove _any_ occurrences. > $_ =~ s/[^[:ascii:]]//g; > my @Command = split(/\ /, $_); There's no need to escape a space character in a regular expression. That would be fine as just / /. Or if you wanted the special awk-like behavior of splitting on multiple white-space characters and trimming the start then you should use " ". > switch($Command['0']) { It doesn't make any sense to quote the 0 here. The string gets converted to an integer index. It should be written as just plain $Command[0]. Additionally, Switch.pm is a hack of a module that uses source filtering to accomplish its goals. It has various limitations and should generally be avoided in production code. I think the preferred mechanism is to simply use an elsif-ladder. I'm not sure if it could be, but it would be interesting if that was the culprit all along. > 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)) { Again you'd be better off using a different variable than $_. $_ can be easily changed on you without being obvious that it has changed. > $self->log(0,Dumper($_)); > print OUTFILE $_; > $size=$size+length($_); I'm assuming all of the lines on the left margin are debugging lines because that's what I do too. I'm ignoring that. > if ($_ =~ /^\.\r\n$/) { This looks suspicious to me, but maybe that's just my ignorance with the protocol. You appear to be reading 4-bytes at a time, but then you're comparing with an extact 3-byte terminator. How do you know that the last 3 bytes will align themselves this way? > 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. That's a reasonable route to take. Be sure to let us know if you do get private help so that we know to stop. :) I'll attempt to look at the files from your latter E-mail, but without having a complete program to work with there's no guarantee I'll even be looking in the right ball park. 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'
signature.asc
Description: Digital signature