This is a live mirror of the Perl 5 development currently hosted at
https://github.com/perl/perl5
https://perl5.git.perl.org
/
perl5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Inline S_procself_val() into S_set_caret_x().
[perl5.git]
/
lib
/
FileHandle.pm
diff --git
a/lib/FileHandle.pm
b/lib/FileHandle.pm
index
b907cae
..
6b3636a
100644
(file)
--- a/
lib/FileHandle.pm
+++ b/
lib/FileHandle.pm
@@
-1,10
+1,10
@@
package FileHandle;
package FileHandle;
-use 5.00
3_11
;
+use 5.00
6
;
use strict;
use strict;
-
use vars qw($VERSION @ISA @EXPORT
@EXPORT_OK);
+
our($VERSION, @ISA, @EXPORT,
@EXPORT_OK);
-$VERSION = "2.0
0
";
+$VERSION = "2.0
2
";
require IO::File;
@ISA = qw(IO::File);
require IO::File;
@ISA = qw(IO::File);
@@
-69,7
+69,8
@@
import IO::Handle grep { !defined(&$_) } @EXPORT, @EXPORT_OK;
sub import {
my $pkg = shift;
my $callpkg = caller;
sub import {
my $pkg = shift;
my $callpkg = caller;
- Exporter::export $pkg, $callpkg, @_;
+ require Exporter;
+ Exporter::export($pkg, $callpkg, @_);
#
# If the Fcntl extension is available,
#
# If the Fcntl extension is available,
@@
-77,7
+78,7
@@
sub import {
#
eval {
require Fcntl;
#
eval {
require Fcntl;
- Exporter::export
'Fcntl', $callpkg
;
+ Exporter::export
('Fcntl', $callpkg)
;
};
}
};
}
@@
-93,6
+94,11
@@
sub pipe {
($r, $w);
}
($r, $w);
}
+# Rebless standard file handles
+bless *STDIN{IO}, "FileHandle" if ref *STDIN{IO} eq "IO::Handle";
+bless *STDOUT{IO}, "FileHandle" if ref *STDOUT{IO} eq "IO::Handle";
+bless *STDERR{IO}, "FileHandle" if ref *STDERR{IO} eq "IO::Handle";
+
1;
__END__
1;
__END__
@@
-105,32
+111,32
@@
FileHandle - supply object methods for filehandles
use FileHandle;
use FileHandle;
- $fh =
new FileHandle
;
- if ($fh->open
"< file"
) {
+ $fh =
FileHandle->new
;
+ if ($fh->open
("< file")
) {
print <$fh>;
$fh->close;
}
print <$fh>;
$fh->close;
}
- $fh =
new FileHandle "> FOO"
;
+ $fh =
FileHandle->new("> FOO")
;
if (defined $fh) {
print $fh "bar\n";
$fh->close;
}
if (defined $fh) {
print $fh "bar\n";
$fh->close;
}
- $fh =
new FileHandle "file", "r"
;
+ $fh =
FileHandle->new("file", "r")
;
if (defined $fh) {
print <$fh>;
undef $fh; # automatically closes the file
}
if (defined $fh) {
print <$fh>;
undef $fh; # automatically closes the file
}
- $fh =
new FileHandle "file", O_WRONLY|O_APPEND
;
+ $fh =
FileHandle->new("file", O_WRONLY|O_APPEND)
;
if (defined $fh) {
print $fh "corge\n";
undef $fh; # automatically closes the file
}
$pos = $fh->getpos;
if (defined $fh) {
print $fh "corge\n";
undef $fh; # automatically closes the file
}
$pos = $fh->getpos;
- $fh->setpos
$pos
;
+ $fh->setpos
($pos)
;
$fh->setvbuf($buffer_var, _IOLBF, 1024);
$fh->setvbuf($buffer_var, _IOLBF, 1024);
@@
-219,7
+225,7
@@
supported C<FileHandle> methods:
Furthermore, for doing normal I/O you might need these:
Furthermore, for doing normal I/O you might need these:
-=over
+=over
4
=item $fh->print
=item $fh->print
@@
-232,17
+238,21
@@
See L<perlfunc/printf>.
=item $fh->getline
This works like <$fh> described in L<perlop/"I/O Operators">
=item $fh->getline
This works like <$fh> described in L<perlop/"I/O Operators">
-except that it's more readable and can be safely called in a
n
-
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 $fh->getlines
=item $fh->getlines
-This works like <$fh> when called in a
n array
context to
+This works like <$fh> 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.
=back
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.
=back
+There are many other functions available since FileHandle is descended
+from IO::File, IO::Seekable, and IO::Handle. Please see those
+respective pages for documentation on more functions.
+
=head1 SEE ALSO
The B<IO> extension,
=head1 SEE ALSO
The B<IO> extension,