$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
=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 )
=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;
}
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 {
}
sub input_line_number {
- # local $. does not work properly, so we need to do it some other
- # way. We use select, although this is not quite right. What we
- # really need to know is the file handle that was the subject of the
- # last read, seek or tell.
- my $now = select;
- my $keep = $.;
- my $tell = tell qualify($_[0], caller) if ref($_[0]);
- my $prev = $.;
- $. = $_[1] if @_ > 1;
- no strict "refs";
- $tell = tell $now;
- $. = $keep;
- $prev;
-}
-
-=for when local $. works properly
-sub input_line_number {
local $.;
my $tell = tell qualify($_[0], caller) if ref($_[0]);
my $prev = $.;
$. = $_[1] if @_ > 1;
$prev;
}
-=cut
sub format_page_number {
my $old = new SelectSaver qualify($_[0], caller) if ref($_[0]);
}
}
+# 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