summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorGisle Aas <aas@bergen.sn.no>1997-06-24 15:46:11 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commitc9de509e331450a10058399280ce28f68f0faf39 (patch)
tree47a8372734a66a69c05b54c67eeb5d9083a315b5 /gv.c
parent44ed422101809141bc33c2b85c1cff357de4d7bf (diff)
downloadperl-c9de509e331450a10058399280ce28f68f0faf39.tar.gz
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
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 6c912a0e9b..8b38bbe19e 100644
--- a/gv.c
+++ b/gv.c
@@ -827,7 +827,9 @@ newIO()
sv_upgrade((SV *)io,SVt_PVIO);
SvREFCNT(io) = 1;
SvOBJECT_on(io);
- iogv = gv_fetchpv("IO::Handle::", TRUE, SVt_PVHV);
+ iogv = gv_fetchpv("FileHandle::", FALSE, SVt_PVHV);
+ if (!iogv)
+ iogv = gv_fetchpv("IO::Handle::", TRUE, SVt_PVHV);
SvSTASH(io) = (HV*)SvREFCNT_inc(GvHV(iogv));
return io;
}