This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a perl592delta.pod man page.
[perl5.git] / pod / perlopentut.pod
index 6d37fb8..3116f78 100644 (file)
@@ -192,11 +192,11 @@ whether it only works on existing files or always clobbers existing ones.
     open(WTMP, "+< /usr/adm/wtmp") 
         || die "can't open /usr/adm/wtmp: $!";
 
-    open(SCREEN, "+> /tmp/lkscreen")
-        || die "can't open /tmp/lkscreen: $!";
+    open(SCREEN, "+> lkscreen")
+        || die "can't open lkscreen: $!";
 
-    open(LOGFILE, "+>> /tmp/applog"
-        || die "can't open /tmp/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
 clobber an old one.  The third one will create a new file if necessary
@@ -602,7 +602,7 @@ welcome to reopen them if you'd like.
     open(STDOUT, "> output")
        || die "can't open output: $!";
 
-And then these can be read directly or passed on to subprocesses.
+And then these can be accessed directly or passed on to subprocesses.
 This makes it look as though the program were initially invoked
 with those redirections from the command line.
 
@@ -625,11 +625,11 @@ just in a different process:
 
     sub head {
         my $lines = shift || 20;
-        return unless $pid = open(STDOUT, "|-");
+        return if $pid = open(STDOUT, "|-");       # return if parent
         die "cannot fork: $!" unless defined $pid;
         while (<STDIN>) {
-            print;
             last if --$lines < 0;
+            print;
         } 
         exit;
     } 
@@ -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;
-    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,
@@ -925,7 +927,7 @@ The two-argument form of C<binmode> is being used, for example
 
 =back
 
-For more detailed discussion about PerlIO see L<perlio>;
+For more detailed discussion about PerlIO see L<PerlIO>;
 for more detailed discussion about Unicode and I/O see L<perluniintro>.
 
 =head1 SEE ALSO