develooper Front page | perl.perl5.porters | Postings from May 2003

Re: [perl #22339] IO::Handle::setvbuf not defined properly

Mark Jason Dominus
May 28, 2003 09:27
Re: [perl #22339] IO::Handle::setvbuf not defined properly
Message ID:

Nicholas Clark <>:
> > a) use setvbuf() to discard the buffer, perhaps temporarily, or
> My understanding is that one never was allowed to call setvbuf() midway on a
> stream:

Right, thanks.  Please forget about the 'perhaps temporarily' part.  I
added this as an afterthought in my message anyway.  The essential
problem is that I would like to do

        $rec = <FH>;

but that implies some sort of buffering, and the buffering confounds
concurrent access.  So I planned to use setvbuf to disabled the
buffering while stil permitting use of <FH>.

Kurt Starsinic <>:
>    How about mmap(), 

I need features that are provided by standard perl, preferably back to
5.005.  As far as I know there's no entry to mmap except through
nonstandard CPAN modules.  PerlIO uses it internally, if it's
available, but doesn't make it available to me.

Kurt Starsinic <>:
> or closing and re-opening the read() filehandle?

Not an option, I'm afraid.  It may not be re-openable.  


        open $newfh, "<&=".fileno($oldfh) 

seems not to work for some reason that I haven't investigated yet.

Graham Barr <>:
> You could try using seek.

That works on my platform, but I worry that it's not portable.  I
can't think of any reason why 'seek' should necessarily discard the
buffered data.  Perhaps I'm overlooking something? Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About