[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl5-porters
Subject:    Re: perlopentut modernization
From:       Alexander Hartmaier <alex.hartmaier () gmail ! com>
Date:       2013-01-29 23:00:40
Message-ID: CAB49QrZnorzJ4dAxpaMkXgZM8GWKQuUKyKM_Cv3bD7fJd0DP+A () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Fri, Jan 25, 2013 at 1:06 AM, Alexander Hartmaier <
alex.hartmaier@gmail.com> wrote:

> On Thu, Jan 24, 2013 at 4:35 AM, Dave Rolsky <autarch@urth.org> wrote:
> 
> > On Wed, 23 Jan 2013, James E Keenan wrote:
> > 
> > On 1/23/13 7:05 PM, Alexander Hartmaier wrote:
> > > 
> > > > As my work environment seems to be too new for what perlhack suggests (
> > > > http://mail.google.com is my mail client) I wasn't able to use perlbug
> > > > to
> > > > submit the patch so I've simply attached it instead.
> > > > 
> > > > Good night, Alex
> > > > 
> > > > 
> > > Based on my first read-through of the patch, I say:  Apply it.
> > > 
> > > There are a few hard-tabs that could be converted to whitespace, and
> > > there are a few places where the copy-editor in me would like to improve
> > > the flow a bit, but as they say in Hollywood, "We can take care of that in
> > > post-."
> > > 
> > > Dave Rolsky:  What do you think?
> > > 
> > 
> > On #p5p today there was some discussion on doing a bigger rewrite based
> > on Leon Timmerman's outline here - https://github.com/Leont/**
> > perlopentut/blob/master/**perlopentut.pod<https://github.com/Leont/perlopentut/blob/master/perlopentut.pod>
> >  
> > Alex expressed interest in working on that. If that's still the case I'd
> > just as soon wait for that.
> 
> Yes, that's still the case if time permits it!
> As the new tutorial will be a ~90% line-change I suggest to apply the
> current patch first to still have better docs in case I'm not able to
> finish the rewrite (refactor? ;-) until 5.18.0 gets released.
> If you agree I'll try to send patch version #2 with Vadim's suggestions in
> the next few days.
> 
> 
> > 
> > 
> > -dave
> > 
> > /*============================**==============================**==
> > http://VegGuide.org               http://blog.urth.org
> > Your guide to all that's veg      House Absolute(ly Pointless)
> > ==============================**==============================***/
> > 
> 
> Attached is the second commit that removes all three mentions of Perl 5.6
and improves the 'Pipe Opens' section, feedback welcome.


[Attachment #5 (text/html)]

<div class="gmail_quote">On Fri, Jan 25, 2013 at 1:06 AM, Alexander Hartmaier <span \
dir="ltr">&lt;<a href="mailto:alex.hartmaier@gmail.com" \
target="_blank">alex.hartmaier@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">

<div class="gmail_quote"><div class="im">On Thu, Jan 24, 2013 at 4:35 AM, Dave Rolsky \
<span dir="ltr">&lt;<a href="mailto:autarch@urth.org" \
target="_blank">autarch@urth.org</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">


<div><div>On Wed, 23 Jan 2013, James E Keenan wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> On 1/23/13 7:05 PM, Alexander Hartmaier wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> As my work environment seems to be too new for what perlhack \
suggests (<br> <a href="http://mail.google.com" \
target="_blank">http://mail.google.com</a> is my mail client) I wasn&#39;t able to \
use perlbug to<br> submit the patch so I&#39;ve simply attached it instead.<br>
<br>
Good night, Alex<br>
<br>
</blockquote>
<br>
Based on my first read-through of the patch, I say:   Apply it.<br>
<br>
There are a few hard-tabs that could be converted to whitespace, and there are a few \
places where the copy-editor in me would like to improve the flow a bit, but as they \
say in Hollywood, &quot;We can take care of that in post-.&quot;<br>



<br>
Dave Rolsky:   What do you think?<br>
</blockquote>
<br></div></div>
On #p5p today there was some discussion on doing a bigger rewrite based on Leon \
Timmerman&#39;s outline here - <a \
href="https://github.com/Leont/perlopentut/blob/master/perlopentut.pod" \
target="_blank">https://github.com/Leont/<u></u>perlopentut/blob/master/<u></u>perlopentut.pod</a><br>




<br>
Alex expressed interest in working on that. If that&#39;s still the case I&#39;d just \
as soon wait for that.</blockquote></div><div>Yes, that&#39;s still the case if time \
permits it!<br>As the new tutorial will be a ~90% line-change I suggest to apply the \
current patch first to still have better docs in case I&#39;m not able to finish the \
rewrite (refactor? ;-) until 5.18.0 gets released.<br>


If you agree I&#39;ll try to send patch version #2 with Vadim&#39;s suggestions in \
the next few days.<br><br></div><div class="im"><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>
<div><br>
<br>
<br>
-dave<br>
<br>
/*============================<u></u>==============================<u></u>==<br>
<a href="http://VegGuide.org" target="_blank">http://VegGuide.org</a>                 \
<a href="http://blog.urth.org" target="_blank">http://blog.urth.org</a><br> Your \
guide to all that&#39;s veg         House Absolute(ly Pointless)<br> \
==============================<u></u>==============================<u></u>*/<br> \
</div></div></blockquote></div></div><br></blockquote><div>Attached is the second \
commit that removes all three mentions of Perl 5.6 and improves the &#39;Pipe \
Opens&#39; section, feedback welcome.<br></div></div>

--e0cb4efe357206922104d4755e08--


["0001-perlopentut-modernization-2.patch" (application/octet-stream)]

From 79c3ba590c7e8d92df5acae250c6e59a63cfa16b Mon Sep 17 00:00:00 2001
From: Alexander Hartmaier <abraxxa@cpan.org>
Date: Tue, 29 Jan 2013 23:50:24 +0100
Subject: [PATCH] perlopentut modernization #2
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------1.7.10.4"

This is a multi-part message in MIME format.
--------------1.7.10.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


- removed all references to Perl 5.6 as per Vadim's suggestion
- improved the 'Pipe Opens' section by removing the references to C,
  moving the list notation examples to the front,
  when using the shell notation makes sense and
  adding an explanation when the shell will be invoked
---
 pod/perlopentut.pod |   71 ++++++++++++++++++++++-----------------------------
 1 file changed, 30 insertions(+), 41 deletions(-)


--------------1.7.10.4
Content-Type: text/x-patch; name="0001-perlopentut-modernization-2.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-perlopentut-modernization-2.patch"

diff --git a/pod/perlopentut.pod b/pod/perlopentut.pod
index da75571..1248bf7 100644
--- a/pod/perlopentut.pod
+++ b/pod/perlopentut.pod
@@ -68,10 +68,9 @@ L<"Dispelling the Dweomer">.
 
 =head2 Indirect Filehandles
 
-C<open>'s first argument can be a reference to a filehandle.  As of
-Perl 5.6.0, if the argument is uninitialized, Perl will automatically
-create a filehandle and put a reference to it in the first argument,
-like so:
+C<open>'s first argument can be a reference to a filehandle. If the argument
+is uninitialized, Perl will automatically create a filehandle and put a
+reference to it in the first argument, like so:
 
     open( my $in, '<', $infile )
         or die "Couldn't read $infile: $!";
@@ -113,14 +112,11 @@ filehandles from subroutines:
 
 =head2 Pipe Opens
 
-In C, when you want to open a file using the standard I/O library,
-you use the C<fopen> function, but when opening a pipe, you use the
-C<popen> function.  But in the shell, you just use a different redirection
-character.  That's also the case for Perl.  The C<open> call
-remains the same--just its argument differs.
+To get a pipe to a program, either reading or writing, you can use the dash
+character in front of or after the pipe character as the mode argument.
 
-If the leading character is a pipe symbol, C<open> starts up a new
-command and opens a write-only filehandle leading into that command.
+If the mode character is a pipe symbol followed by a dash, C<open> starts up
+a new command and opens a write-only filehandle leading into that command.
 This lets you write into that handle and have what you write show up on
 that command's standard input.  For example:
 
@@ -130,9 +126,9 @@ that command's standard input.  For example:
     close($printer)
         or die "can't close lpr: $!";
 
-If the trailing character is a pipe, you start up a new command and open a
-read-only filehandle leading out of that command.  This lets whatever that
-command writes to its standard output show up on your handle for reading.
+If the dash character is ahead of the pipe, you start up a new command and
+open a read-only filehandle leading out of that command. This lets whatever
+that command writes to its standard output show up on your handle for reading.
 For example:
 
     open(my $net, '-|', 'netstat', '-i', '-n')
@@ -156,31 +152,24 @@ If you would like to open a bidirectional pipe, the IPC::Open2
 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 RISC OS.)
-
-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($_);
+If you already have a shell snippet you can put it into the third argument
+without splitting the command and its parameters. This will invoke the shell
+if shell metacharacters are found which is unsafer, slower and foremost less
+portable than using the list notation but allows special shell constructs.
+It is not supported on Microsoft Windows and RISC OS.
+
+Here's an example of C<open '-|'>, which reads the contents of a gzipped tar
+file into an array:
+
+    my $file = shift(@ARGV);
+    open(my $fh, '-|', "zcat ${file} | tar xfv -")
+        or die "Could not get contents of compressed file: $!";
+    my @filenames;
+    while (<$fh>) {
+        chomp;                  # remove line-feed
+        push @filenames, $_;
     }
-    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: $!";
+    close($fh);
 
 =head2 The Minus File
 
@@ -374,9 +363,9 @@ Less common flags that are sometimes available on some operating
 systems include C<O_BINARY>, C<O_TEXT>, C<O_SHLOCK>, C<O_EXLOCK>,
 C<O_DEFER>, C<O_SYNC>, C<O_ASYNC>, C<O_DSYNC>, C<O_RSYNC>,
 C<O_NOCTTY>, C<O_NDELAY> and C<O_LARGEFILE>.  Consult your open(2)
-manpage or its local equivalent for details.  (Note: starting from
-Perl release 5.6 the C<O_LARGEFILE> flag, if available, is automatically
-added to the sysopen() flags because large files are the default.)
+manpage or its local equivalent for details.
+(Note: the C<O_LARGEFILE> flag, if available, is automatically 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<or die $!> checks for clarity, but make sure

--------------1.7.10.4--




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic