summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/IO/Handle.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/IO/Handle.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/IO/Handle.pm25
1 files changed, 18 insertions, 7 deletions
diff --git a/Master/tlpkg/tlperl/lib/IO/Handle.pm b/Master/tlpkg/tlperl/lib/IO/Handle.pm
index 2f1f1b423bc..6ca3c8a35d6 100644
--- a/Master/tlpkg/tlperl/lib/IO/Handle.pm
+++ b/Master/tlpkg/tlperl/lib/IO/Handle.pm
@@ -8,13 +8,13 @@ IO::Handle - supply object methods for I/O handles
use IO::Handle;
- $io = new IO::Handle;
+ $io = IO::Handle->new();
if ($io->fdopen(fileno(STDIN),"r")) {
print $io->getline;
$io->close;
}
- $io = new IO::Handle;
+ $io = IO::Handle->new();
if ($io->fdopen(fileno(STDOUT),"w")) {
$io->print("Some text\n");
}
@@ -268,7 +268,7 @@ use IO (); # Load the XS module
require Exporter;
@ISA = qw(Exporter);
-$VERSION = "1.28";
+$VERSION = "1.31";
$VERSION = eval $VERSION;
@EXPORT_OK = qw(
@@ -309,14 +309,25 @@ $VERSION = eval $VERSION;
sub new {
my $class = ref($_[0]) || $_[0] || "IO::Handle";
- @_ == 1 or croak "usage: new $class";
+ if (@_ != 1) {
+ # Since perl will automatically require IO::File if needed, but
+ # also initialises IO::File's @ISA as part of the core we must
+ # ensure IO::File is loaded if IO::Handle is. This avoids effect-
+ # ively "half-loading" IO::File.
+ if ($] > 5.013 && $class eq 'IO::File' && !$INC{"IO/File.pm"}) {
+ require IO::File;
+ shift;
+ return IO::File::->new(@_);
+ }
+ croak "usage: $class->new()";
+ }
my $io = gensym;
bless $io, $class;
}
sub new_from_fd {
my $class = ref($_[0]) || $_[0] || "IO::Handle";
- @_ == 3 or croak "usage: new_from_fd $class FD, MODE";
+ @_ == 3 or croak "usage: $class->new_from_fd(FD, MODE)";
my $io = gensym;
shift;
IO::Handle::fdopen($io, @_)
@@ -603,8 +614,8 @@ sub ioctl {
return ioctl($io, $op, $_[2]);
}
-# this sub is for compatability with older releases of IO that used
-# a sub called constant to detemine if a constant existed -- GMB
+# this sub is for compatibility with older releases of IO that used
+# a sub called constant to determine if a constant existed -- GMB
#
# The SEEK_* and _IO?BF constants were the only constants at that time
# any new code should just chech defined(&CONSTANT_NAME)