> >From "Perl 5 for Dummies": > > "read(HANDLE, VARIABLE, LENGTH, POSITION); > > The Variable is the place where you want to read into, the length is the > number of bytes to read, and the position is the byte in the file to > start reading from." > > it says that if you leave the Position empty, then it uses the current > file position, but if you put a number there, that is the starting point. > Is this totally wrong? Youch. Close enough to confuse. According to the POD (or the Camel, take your pick) OFFSET (aka POSITION) isn't the position in the file to start reading from, it's the position in the scalar to read _to_. A subtle difference but a major one! read FILEHANDLE,SCALAR,LENGTH,OFFSET Attempts to read LENGTH bytes of data into variable SCALAR from the specified FILEHANDLE. Returns the number of bytes actually read, or undef if there was an error. ... An OFFSET may be specified to place the read data at some other place than the beginning of the string. > Is "read" only meant for Text > files, and "sysread" for binary files? Can you do a regular "open" > command, and then do a "sysread"? Open is unrelated to the choice of read vs. sysread; open simply gets you the FILEHANDLE. Perl's read is implemented with the Standard I/O function; sysread isn't. Schools of thought differ on whether to use Standard I/O (which handles some magic for you) or not. My school of thought says there is nothing wrong with using read :-) --- Vicki Brown, vlb@cfcl.com |\ _,,,---,,_ Journeyman Sourceror ZZZzz /,`.-'`' -. ;-;;,_ Scripts & Philtres |,4- ) )-,_. ,\ ( `'-' http://www.cfcl.com/~vlb '---''(_/--' `-'\_) P.O. Box 1269 San Bruno, CA 94066 ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch