http://qs321.pair.com?node_id=322524


in reply to Transmit file over socket

I think your server has a logic error. Consider your code:
... print "Got: $in\n"; if ($in =~ /#:#$/) { ... } elsif ($in =~ /_$/) { ... } elsif ($in =~ /__END$/) { ... } else { ... # save file }
For the following input data:
Got: X-Call~4.xml#:#380_<?xml version="1.0"?>
Your logic will never get to the save file bit correctly, it will (almost) always fall inside the $in =~ /_$/ block and not saving the xml header correctly.


You probably want something like this instead:
if ($in =~ /__END$/) { # close previous file } else { ($filename, $filesize) = $in =~ /^([^#]+)#:#(\d+)_/; if ($filename) { # create new file } # proceed with saving the file }