This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
bless file handles as FileHandle if loaded else IO::Handle
authorGisle Aas <aas@bergen.sn.no>
Tue, 24 Jun 1997 03:46:11 +0000 (15:46 +1200)
committerTim Bunce <Tim.Bunce@ig.co.uk>
Wed, 6 Aug 1997 12:00:00 +0000 (00:00 +1200)
commitc9de509e331450a10058399280ce28f68f0faf39
tree47a8372734a66a69c05b54c67eeb5d9083a315b5
parent44ed422101809141bc33c2b85c1cff357de4d7bf
bless file handles as FileHandle if loaded else IO::Handle

Subject: Re: More info regarding the Can't locate error message [PATCH]

lvirden@cas.org (Larry W. Virden) writes:

> use FileHandle;
> STDERR->open("/tmp/errorsfile","w");

This patch tries to fix the problem by auto-blessing handles as
'FileHandle' if the FileHandle package has been loaded and IO::Handle
otherwise.  The snag is that STDOUT, STDIN, STDERR are initialized
before 'use FileHandle' executes, so they are all initially blessed as
IO::Handles.  We compensate by reblessing them in FileHandle.pm:

This makes Larry's example as well as the following code work:

  use FileHandle;
  open(F, "/dev/null") or die;
  F->seek(0, 1) or die;

p5p-msgid: hyb80drrz.fsf@bergen.sn.no
gv.c
lib/FileHandle.pm