This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Filehandle method calls load IO::File on demand
authorDavid Golden <dagolden@cpan.org>
Mon, 29 Nov 2010 04:12:12 +0000 (23:12 -0500)
committerDavid Golden <dagolden@cpan.org>
Mon, 29 Nov 2010 20:30:50 +0000 (15:30 -0500)
commit15e6cdd91beb4cefae4b65e855d68cf64766965d
tree9b22cf13e30a346c10c6dce7d2531d9e002e9d62
parenta812f6a926c0966af8d2a9a3d2d05fe1a5df510f
Filehandle method calls load IO::File on demand

When a method call on a filehandle would die because the method can not
be resolved and L<IO::File> has not been loaded, Perl now loads IO::File
via C<require> and attempts method resolution again:

  open my $fh, ">", $file;
  $fh->binmode(":raw");     # loads IO::File and succeeds

This also works for globs like STDOUT, STDERR and STDIN:

  STDOUT->autoflush(1);

Because this on-demand load only happens if method resolution fails, the
legacy approach of manually loading an IO::File parent class for partial
method support still works as expected:

  use IO::Handle;
  open my $fh, ">", $file;
  $fh->autoflush(1);        # IO::File not loaded
MANIFEST
gv.c
pod/perldelta.pod
t/io/iofile.t [new file with mode: 0644]
t/io/open.t