develooper Front page | perl.perl5.porters | Postings from August 2008

Re: Near-FMTEYEWTK instructorial on ties, handles, and methods (was: How to tell whether readline got an error or EOF)

Thread Previous | Thread Next
From:
Ed Avis
Date:
August 2, 2008 16:35
Subject:
Re: Near-FMTEYEWTK instructorial on ties, handles, and methods (was: How to tell whether readline got an error or EOF)
Message ID:
loom.20080802T232925-216@post.gmane.org
Thank you for the explanation.  I think I understand the essential
point that there is a difference between filehandle methods like READ
and SEEK, which can be implemented by a tied filehandle class, and
IO::Handle functions like error and flush, which depend on having a
real filehandle.

Given this, let me rephrase my question:

If I call getc() on a filehandle and it returns undef, how can I tell
if that undef was caused by end of file or by an error?  The
filehandle could be a real one or it could be a tied filehandle.

(Clearly, if you allow arbitrary tied filehandle code then all bets
are off, so let me stipulate that any tied class used is assumed to be
non-buggy and to deal with error handling in the way it should.)

Secondly, if I am writing a tied filehandle class myself what
guarantees should I provide to the caller of GETC so the caller can
detect error conditions correctly?

-- 
Ed Avis <eda@waniasset.com>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About