[Wylug-help] Perl v. Python oddity

Dave Whiteley d.l.whiteley at ee.leeds.ac.uk
Wed, 29 Jan 2003 16:30:07 +0000


Hello All,

For reasons too complicated to explain, I am writing some code to copy
an image of a file from one machine to another over network sockets.

The file to be copied will be coming from a M$ box, and will be stored
on a Linux box.  The files could be text or binary. I am trying to use
an MD5 hashing to check that the files are identical.  I am developing
this on a single Linux box.

Just to make things interesting ( he means idiotic!) the client
(sender) is in perl, and the server (receiver) in python. ( I am using
it as a chance to learn some Python.)

It is working but......

The received file is getting one extra newline at the end, which is,
of course, screwing up the hashing. Remove the newline with an editor,
and the hashes match.

I am reading the file in perl using fixed sized blocks
   read WORK, $text, 80

and writing it in python with
   print >> fh, text

The file is many blocks long, so all but the last one are copying OK.

Is there something I should know about the behaviour of Perl versus
Python in the way that end of file is handled?

Dave




--
Dave Whiteley
d.l.whiteley@ee.leeds.ac.uk
Phone +44 (0)113 343 2059
School of Electronic and Electrical Engineering
The University of Leeds. Leeds, LS2 9JT,  UK