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
[patch] :utf8 updates
[perl5.git]
/
pod
/
perlopentut.pod
diff --git
a/pod/perlopentut.pod
b/pod/perlopentut.pod
index
0b60096
..
18bc369
100644
(file)
--- a/
pod/perlopentut.pod
+++ b/
pod/perlopentut.pod
@@
-67,7
+67,7
@@
examples would effectively mean
which is definitely not what you want.
The other important thing to notice is that, just as in the shell,
which is definitely not what you want.
The other important thing to notice is that, just as in the shell,
-any white
space before or after the filename is ignored. This is good,
+any whitespace before or after the filename is ignored. This is good,
because you wouldn't want these to do different things:
open INFO, "<datafile"
because you wouldn't want these to do different things:
open INFO, "<datafile"
@@
-82,7
+82,7
@@
in from a different file, and forget to trim it before opening:
This is not a bug, but a feature. Because C<open> mimics the shell in
its style of using redirection arrows to specify how to open the file, it
This is not a bug, but a feature. Because C<open> mimics the shell in
its style of using redirection arrows to specify how to open the file, it
-also does so with respect to extra white
space around the filename itself
+also does so with respect to extra whitespace around the filename itself
as well. For accessing files with naughty names, see
L<"Dispelling the Dweomer">.
as well. For accessing files with naughty names, see
L<"Dispelling the Dweomer">.
@@
-195,7
+195,7
@@
whether it only works on existing files or always clobbers existing ones.
open(SCREEN, "+> lkscreen")
|| die "can't open lkscreen: $!";
open(SCREEN, "+> lkscreen")
|| die "can't open lkscreen: $!";
- open(LOGFILE, "+>> /var/log/applog"
+ open(LOGFILE, "+>> /var/log/applog"
)
|| die "can't open /var/log/applog: $!";
The first one won't create a new file, and the second one will always
|| die "can't open /var/log/applog: $!";
The first one won't create a new file, and the second one will always
@@
-230,7
+230,7
@@
on each file in @ARGV. Thus a program called like this:
$ myprogram file1 file2 file3
$ myprogram file1 file2 file3
-
C
an have all its files opened and processed one at a time
+
c
an have all its files opened and processed one at a time
using a construct no more complex than:
while (<>) {
using a construct no more complex than:
while (<>) {
@@
-332,7
+332,7
@@
C<sysopen> takes 3 (or 4) arguments.
The HANDLE argument is a filehandle just as with C<open>. The PATH is
a literal path, one that doesn't pay attention to any greater-thans or
The HANDLE argument is a filehandle just as with C<open>. The PATH is
a literal path, one that doesn't pay attention to any greater-thans or
-less-thans or pipes or minuses, nor ignore white
space. If it's there,
+less-thans or pipes or minuses, nor ignore whitespace. If it's there,
it's part of the path. The FLAGS argument contains one or more values
derived from the Fcntl module that have been or'd together using the
bitwise "|" operator. The final argument, the MASK, is optional; if
it's part of the path. The FLAGS argument contains one or more values
derived from the Fcntl module that have been or'd together using the
bitwise "|" operator. The final argument, the MASK, is optional; if
@@
-364,7
+364,7
@@
added to the sysopen() flags because large files are the default.)
Here's how to use C<sysopen> to emulate the simple C<open> calls we had
before. We'll omit the C<|| die $!> checks for clarity, but make sure
you always check the return values in real code. These aren't quite
Here's how to use C<sysopen> to emulate the simple C<open> calls we had
before. We'll omit the C<|| die $!> checks for clarity, but make sure
you always check the return values in real code. These aren't quite
-the same, since C<open> will trim leading and trailing white
space,
+the same, since C<open> will trim leading and trailing whitespace,
but you'll get the idea.
To open a file for reading:
but you'll get the idea.
To open a file for reading:
@@
-487,7
+487,7
@@
If the filehandle or descriptor number is preceded not just with a simple
"&" but rather with a "&=" combination, then Perl will not create a
completely new descriptor opened to the same place using the dup(2)
system call. Instead, it will just make something of an alias to the
"&" but rather with a "&=" combination, then Perl will not create a
completely new descriptor opened to the same place using the dup(2)
system call. Instead, it will just make something of an alias to the
-existing one using the fdopen(3S) library call This is slightly more
+existing one using the fdopen(3S) library call
.
This is slightly more
parsimonious of systems resources, although this is less a concern
these days. Here's an example of that:
parsimonious of systems resources, although this is less a concern
these days. Here's an example of that:
@@
-521,7
+521,7
@@
working directory, slash the directory separator, and disallows ASCII
NULs within a valid filename. Most systems follow these conventions,
including all POSIX systems as well as proprietary Microsoft systems.
The only vaguely popular system that doesn't work this way is the
NULs within a valid filename. Most systems follow these conventions,
including all POSIX systems as well as proprietary Microsoft systems.
The only vaguely popular system that doesn't work this way is the
-
proprietary
Macintosh system, which uses a colon where the rest of us
+
"Classic"
Macintosh system, which uses a colon where the rest of us
use a slash. Maybe C<sysopen> isn't such a bad idea after all.
If you want to use C<< <ARGV> >> processing in a totally boring
use a slash. Maybe C<sysopen> isn't such a bad idea after all.
If you want to use C<< <ARGV> >> processing in a totally boring
@@
-723,7
+723,9
@@
With descriptors that you haven't opened using C<sysopen>, such as
sockets, you can set them to be non-blocking using C<fcntl>:
use Fcntl;
sockets, you can set them to be non-blocking using C<fcntl>:
use Fcntl;
- fcntl(Connection, F_SETFL, O_NONBLOCK)
+ my $old_flags = fcntl($handle, F_GETFL, 0)
+ or die "can't get flags: $!";
+ fcntl($handle, F_SETFL, $old_flags | O_NONBLOCK)
or die "can't set non blocking: $!";
Rather than losing yourself in a morass of twisting, turning C<ioctl>s,
or die "can't set non blocking: $!";
Rather than losing yourself in a morass of twisting, turning C<ioctl>s,
@@
-915,7
+917,7
@@
second argument contains something else in addition to the usual
C<< '<' >>, C<< '>' >>, C<< '>>' >>, C<< '|' >> and their variants,
for example:
C<< '<' >>, C<< '>' >>, C<< '>>' >>, C<< '|' >> and their variants,
for example:
- open(my $fh, "<:
utf8
", $fn);
+ open(my $fh, "<:
crlf
", $fn);
=item *
=item *