in reply to How do I create an IO::All object from a pre-existing filehandle
The problem apparently is that it is being checked if $self->_handle is defined, but then ->opened is being called on $self->io_handle, which is undefined in your case.
if (defined $self->pathname) { $self->io_handle(IO::File->new); $self->io_handle->open($self->pathname, @args) or $self->throw($self->open_msg); } elsif (defined $self->_handle and not $self->io_handle->opened # <-- line 88 ) { # XXX Not tested $self->io_handle->fdopen($self->_handle, @args); }
I think that piece of code should be
... elsif (defined $self->_handle) { if ($self->_handle->opened) { # already open ? --> set/use it $self->io_handle($self->_handle); } else { # not open --> open it # XXX Not tested $self->io_handle->fdopen($self->_handle, @args); } }
At least that works for me with your test case. Not sure about the else "XXX Not tested" branch, though... (probably still wrong, because I suppose the ->fdopen() would fail as well (just like ->opened), in case $self->io_handle is undefined).
|
|---|