On Wed, Jan 25, 2006 at 04:17:22PM -0800, Yitzchak Scott-Thoennes wrote:
> > Incidentally, can anyone tell me why I have to do:
> >
> >     my $fh = $self->output_fh ();
> >     my $oldfh = select $fh;
> >     my $oldflush = $|;
> >     $| = 1;
> >     print $fh '';
> >     $| = $oldflush;
> >     select $oldfh;
> >
> > instead of the obvious:
> >
> >     my $fh = $self->output_fh ();
> >     $fh->flush ();
> >
> > which the IO::Handle documentation seems to indicate is supposed to work?
> > If I do the latter, I just get "Can't locate object method "flush" via
> > package "IO::Handle" at ../blib/lib/Pod/Text.pm line 594."  This is with
> > Perl 5.8.7.
> 
> Because perl automatically pseudo-blesses filehandles into either
> FileHandle or IO::Handle, but doesn't actually load the modules.

With this piece of evil in Perl_newIO

    iogv = gv_fetchpvn_flags("FileHandle::", 12, 0, SVt_PVHV);
    /* unless exists($main::{FileHandle}) and defined(%main::FileHandle::) */
    if (!(iogv && GvHV(iogv) && HvARRAY(GvHV(iogv))))
      iogv = gv_fetchpvn_flags("IO::Handle::", 12, TRUE, SVt_PVHV);
    SvSTASH_set(io, (HV*)SvREFCNT_inc(GvHV(iogv)));
    return io;

Nicholas Clark

Reply via email to