Change 34435 by [EMAIL PROTECTED] on 2008/09/27 15:22:20

        Subject: Re: [PATCH] Add open "|-" and open "-|" to perlopentut
        From: Shlomi Fish <[EMAIL PROTECTED]>
        Date: Tue, 23 Sep 2008 19:00:41 +0300
        Message-id: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/pod/perlopentut.pod#27 edit

Differences ...

==== //depot/perl/pod/perlopentut.pod#27 (text) ====
Index: perl/pod/perlopentut.pod
--- perl/pod/perlopentut.pod#26~33559~  2008-03-25 02:46:25.000000000 -0700
+++ perl/pod/perlopentut.pod    2008-09-27 08:22:20.000000000 -0700
@@ -165,6 +165,33 @@
 library will handle this for you.  Check out 
 L<perlipc/"Bidirectional Communication with Another Process">
 
+perl-5.6.x introduced a version of piped open that executes a process
+based on its command line arguments without relying on the shell. (Similar
+to the C<system(@LIST)> notation.) This is safer and faster than executing
+a single argument pipe-command, but does not allow special shell
+constructs. (It is also not supported on Microsoft Windows, Mac OS Classic
+or RiscOS.)
+
+Here's an example of C<open '-|'>, which prints a random Unix
+fortune cookie as uppercase:
+
+    my $collection = shift(@ARGV);
+    open my $fortune, '-|', 'fortune', $collection
+        or die "Could not find fortune - $!";
+    while (<$fortune>)
+    {
+        print uc($_);
+    }
+    close($fortune);
+
+And this C<open '|-'> pipes into lpr:
+
+    open my $printer, '|-', 'lpr', '-Plp1'
+        or die "can't run lpr: $!";
+    print {$printer} "stuff\n";
+    close($printer)
+        or die "can't close lpr: $!";
+
 =head2 The Minus File
 
 Again following the lead of the standard shell utilities, Perl's
End of Patch.

Reply via email to