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

Re: New feature proposal : <<>> to disable magic open of ARGV

Thread Previous | Thread Next
Peter Martini
July 27, 2014 14:11
Re: New feature proposal : <<>> to disable magic open of ARGV
Message ID:
On 7/24/14, Rafael Garcia-Suarez <> wrote:
> I believe that this was discussed here some years ago, and that this
> was suggested by TomC. Anyway, I pushed a patch on rgs/nomagicopen.
> The patch is incomplete as it lacks docs and tests. I welcome feedback
> on the intent of the feature.
> commit 7f5bb3418c4fc2d6e2523bf918a7d9e33f9a7acc
> Author: Rafael Garcia-Suarez <>
> Date:   Thu Jul 24 17:43:29 2014 +0200
>     Introduce the double-diamond operator <<>>
>     This operator works like <> or <ARGV>, as it reads the list of file
>     names to open from the command-line arguments. However, it disables
>     the magic-open feature (that forks to execute piped commands) :
>         $ bleadperl -e 'while(<>){print}' 'echo foo |'
>         foo
>         $ bleadperl -e 'while(<<>>){print}' 'echo foo |'
>         Can't open echo foo |: No such file or directory at -e line 1.

I definitely like the idea in some form, though I'll sit out the
feature/syntax discussion for the moment.  I want to clarify the
framing of the feature though:

When you say 'disable magic-open', a more precise description might be
'Changes ARGV handling to use 3 arg open instead of 2 arg open',
correct?  That way its a little more clearly tied to 2 arg / 3 arg
open discussions and makes it easier to spot the edge cases.

Phrasing it that way makes it a little clearer where the magic comes
from and what other things would be affected; for instance (I can't
test this right now)

perl -e 'print while(<<>>)' '-'

would now only work on a file literally named '-'?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About