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

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

Thread Previous | Thread Next
From:
Abigail
Date:
July 20, 2011 05:20
Subject:
Re: [PATCH] [DOCS] Modernize perlopentut.pod
Message ID:
20110720122008.GB29844@almanda
On Wed, Jul 20, 2011 at 12:03:54PM +0000, Ed Avis wrote:
> 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).


Indeed.

And we help (beginners or otherwise) even less by pretending B doesn't
exists, or (worse) that it's something evil.


Don't forget we all dealt well with 2-arg open for a decade and a half
without our servers being hijacked by every script that opened a file.



Abigail

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