barries <[EMAIL PROTECTED]> wrote:
> On Fri, Nov 17, 2000 at 03:51:35PM +1100, Steve Smith wrote:
> >     seek $f, 0, 0;
>
> Had a look in Apache::File (below), and it sysopens, so you might want
> to sysseek(...) instead.

Just to clear up one thing: sysopen() doesn't actually belong to the
sys* family of functions (syswrite, sysread, sysseek).  File handles
under perl are buffered by default, whether you open them with perl's
open() or with sysopen().  Internally sysopen() does a plain libc
open(), but then it follows with a fdopen() call to get a stdio handle
anyway.

Example (Linux 2.2):
$ strace -e trace=open,write,close,nanosleep perl -MFcntl -e 'sysopen(FH, "/tmp/bla", 
O_WRONLY|O_CREAT); print FH "hey"; sleep 1; print FH "hoy\n"; close FH;'
[ ... ]
open("/tmp/bla", O_WRONLY|O_CREAT|O_LARGEFILE, 0666) = 3
nanosleep({1, 0}, {1, 0})               = 0
write(3, "heyhoy\n", 7)                 = 7
close(3)                                = 0

So the rule of thumb is: use either sysread/syswrite/sysseek, or
read/<>/print/seek, but don't mix the two sets on the same filehandle.
But you can open your filehandles with open(), sysopen() or any of the
OO file packages, as you see fit; both sets of IO functions will work on
a filehandle no matter how it was opened.

Personally, I don't like the magic parsing in open(), so I tend to use
sysopen() always, in combination with the usual read/<>/print/seek.

-- 
Roger Espel Llima, [EMAIL PROTECTED]
http://www.iagora.com/~espel/index.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to