develooper Front page | perl.perl5.porters | Postings from January 2001

Error reporting for PerlIO layers.

January 19, 2001 13:27
Error reporting for PerlIO layers.
Message ID:

Consider the idiom:

open($fh,"<$path") || die "Cannot open $path:$!";

If we add layers/disciplines to that one gets:

open($fh,"<:encoding(gibberish)",$path) || die "Cannot open $path:$!";

Now if $path does not exist etc. then errno i.e. $! is just fine.
But what should happen if (as here) the file is fine but the layer
has problems?

My best guess is that errno should be forced to EINVAL and the whole 
open should fail. But do we want to warn() "Unknown encoding 'gibberish'"
as well?

Or should string value of $! have additional behind the scenes magic 
that looks at a perl-only PL_errno_detail as well?
The snag being when to reset that.

Nick Ing-Simmons Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About