[Bioperl-l] SeqIO fixing: detecting if a filehandle is open for writing

Peter van Heusden pvh at egenetics.com
Thu Aug 5 10:13:38 EDT 2004


Hilmar Lapp wrote:

> Quite frankly IMNSHO if you open a file for reading and then - 
> unsuccessfully - try to write to the file this is not a bioperl error, 
> or perl error for that matter, but a programming error. Perl will be 
> no more verbose if you do this ... at least as far as I'm aware.
>
> I.e., the documentation should be that if you do an operation to a 
> file or SeqIO handle for which you did not open it in the first place 
> then the behavior is undefined.
>
Yep, as I said in my documentation, the options are fix the 
documentation or fix the code. I acknowledge that this is programming 
error - but the implication is that a single typo (no '>' when opening 
the file) results in silent failure - i.e. it appears to work, but 
doesn't. The Perl behaviour is slightly different (not that I think 
anyone checks these things): if you do 'print $fh "FOO\n"' and $fh is 
open for reading only, the return value of print is undef (otherwise it 
is 1).

There might not be anything do-able about this case, but as far as 
possible I think that reasonable programmer errors should be caught.

Peter



More information about the Bioperl-l mailing list