develooper Front page | perl.perl5.porters | Postings from July 2011

Re: [PATCH] [DOCS] Modernize perlopentut.pod

Thread Previous | Thread Next
From:
Ed Avis
Date:
July 20, 2011 05:04
Subject:
Re: [PATCH] [DOCS] Modernize perlopentut.pod
Message ID:
loom.20110720T135309-935@post.gmane.org
Greg Lindahl <greg <at> blekko.com> writes:

>We train a large fraction of our new employees to use perl. We don't
>use any of the perl beginner documentation for the initial training
>because it teaches them things that we don't have and don't want in
>our code. In this particular example, I think the ideal would be to
>start with lots of 3-arg opens and variables as filehandles, and then
>mention that 2-arg open and FH exists.

+1 to that.  If you teach the two-arg open, you must include a long list of
caveats listing all the cases where it does something magic.  Once you have done
so there is no longer any simplicity advantage to the two-arg form.

Beginner material must teach idioms which work reliably 100% of the time, not
interesting hacks which appear to accomplish the task but contain subtle magic
which will do something weird when the filename is '-' or starts with a >
character, although on the other hand you can prefix it with ./ to prevent that,
provided you also make sure it doesn't end in '|', etc etc...

Indeed there is a case for two separate tutorials:

    A.  How to open a file.

    B.  How to use Perl's magic 'open' to do interesting things with
        redirections and shell pipelines, provided you understand that it's not
        in general safe to use string interpolation with a user-provided
        filename.

We do not help beginners by giving them (B) purporting to be (A).

-- 
Ed Avis <eda@waniasset.com>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About