SYN SYN
[p5sagit/p5-mst-13.2.git] / ext / IO / lib / IO / Handle.pm
index 30ee2e5..b6cb410 100644 (file)
@@ -71,7 +71,7 @@ corresponding built-in functions:
     $io->printf ( FMT, [ARGS] )
     $io->stat
     $io->sysread ( BUF, LEN, [OFFSET] )
-    $io->syswrite ( BUF, LEN, [OFFSET] )
+    $io->syswrite ( BUF, [LEN, [OFFSET]] )
     $io->truncate ( LEN )
 
 See L<perlvar> for complete descriptions of each of the following
@@ -115,13 +115,13 @@ Returns true if the object is currently a valid file descriptor.
 =item $io->getline
 
 This works like <$io> described in L<perlop/"I/O Operators">
-except that it's more readable and can be safely called in an
-array context but still returns just one line.
+except that it's more readable and can be safely called in a
+list context but still returns just one line.
 
 =item $io->getlines
 
-This works like <$io> when called in an array context to
-read all the remaining lines in a file, except that it's more readable.
+This works like <$io> when called in a list context to read all
+the remaining lines in a file, except that it's more readable.
 It will also croak() if accidentally called in a scalar context.
 
 =item $io->ungetc ( ORD )
@@ -232,9 +232,9 @@ Derived from FileHandle.pm by Graham Barr E<lt>F<gbarr@pobox.com>E<gt>
 
 =cut
 
-require 5.000;
+require 5.005_64;
 use strict;
-use vars qw($VERSION @EXPORT_OK @ISA);
+our($VERSION, @EXPORT_OK, @ISA);
 use Carp;
 use Symbol;
 use SelectSaver;
@@ -417,14 +417,19 @@ sub sysread {
 }
 
 sub write {
-    @_ == 3 || @_ == 4 or croak 'usage: $io->write(BUF, LEN [, OFFSET])';
+    @_ >= 2 && @_ <= 4 or croak 'usage: $io->write(BUF [, LEN [, OFFSET]])';
     local($\) = "";
+    $_[2] = length($_[1]) unless defined $_[2];
     print { $_[0] } substr($_[1], $_[3] || 0, $_[2]);
 }
 
 sub syswrite {
-    @_ == 3 || @_ == 4 or croak 'usage: $io->syswrite(BUF, LEN [, OFFSET])';
-    syswrite($_[0], $_[1], $_[2], $_[3] || 0);
+    @_ >= 2 && @_ <= 4 or croak 'usage: $io->syswrite(BUF [, LEN [, OFFSET]])';
+    if (defined($_[2])) {
+       syswrite($_[0], $_[1], $_[2], $_[3] || 0);
+    } else {
+       syswrite($_[0], $_[1]);
+    }
 }
 
 sub stat {
@@ -547,18 +552,18 @@ sub format_write {
     }
 }
 
+# XXX undocumented
 sub fcntl {
     @_ == 3 || croak 'usage: $io->fcntl( OP, VALUE );';
-    my ($io, $op, $val) = @_;
-    my $r = fcntl($io, $op, $val);
-    defined $r && $r eq "0 but true" ? 0 : $r;
+    my ($io, $op) = @_;
+    return fcntl($io, $op, $_[2]);
 }
 
+# XXX undocumented
 sub ioctl {
     @_ == 3 || croak 'usage: $io->ioctl( OP, VALUE );';
-    my ($io, $op, $val) = @_;
-    my $r = ioctl($io, $op, $val);
-    defined $r && $r eq "0 but true" ? 0 : $r;
+    my ($io, $op) = @_;
+    return ioctl($io, $op, $_[2]);
 }
 
 # this sub is for compatability with older releases of IO that used