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

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

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
September 30, 2014 20:44
Subject:
Re: New feature proposal : <<>> to disable magic open of ARGV
Message ID:
CAMoYMM_Capd7oSZDk9JDYsGuntAH0PbyMVQSs53Egh2U+bz4Jw@mail.gmail.com
On 30 September 2014 18:17, Father Chrysostomos <sprout@cpan.org> wrote:
> Rafael Garcia-Suarez wrote:
>> > It looks as though you have changed the behaviour of eof(), though I
>> > have not tried building it yet.
>>
>> Maybe, but I don't see where?
>
> OK, I think I misread the code.  I guess it's the double negative of
> 'nomagicopen' being set to FALSE that confused me.
>
>> By the way, I just pushed a test
>> involving eof and <<>> as ad77c200c8a4ed.
>
> I don't see eof() in that commit, though the test you added is
> a good one.

Not explicitly, but I wanted to test that opening the next file
was DTRT. (Also, so many tests missing...)

>> eof() (with empty parentheses)
>> still continues to open the next file the old way.
>>
>> > Would it not be better to flag in GvEGVx(PL_argvgv) to remember which
>> > of <>/<<>> was last used?  There is plenty of room in GvFLAGS.
>>
>> What would that solve? The point is that <> and <<>> differ on how they
>> open the next upcoming file. This is not a property of ARGV.
>
> If I understand correctly, eof() tries opening the next file at an
> individual file's EOF.  I thought you might consider having it reuse
> the last <> or <<>>, to avoid giving a false sense of security to peo-
> ple who do:
>
> while (<<>>) {
>     ...
>     blah_blah_blah() if eof();
> }
>
> where the eof() might to a 2-arg open.

This is a good point, and <<>> does not solve this problem. I should
at least make that explicit in the docs. But it would be better if we
could just "stick" the nomagicopen flag to eof(). (I hate the eof()/eof
distinction and avoid using those for that reason)

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