develooper Front page | perl.perl5.porters | Postings from April 2008

Re: bug in if(open(my $fh,...))

Thread Previous | Thread Next
From:
Bram
Date:
April 28, 2008 12:33
Subject:
Re: bug in if(open(my $fh,...))
Message ID:
20080428213235.ofj61klxws4gwkg4@horde.wizbit.be
>> A proper fix would be to add an "invisible" block around the if. That
>> would slow down all ifs a bit, though.
>
> I don't think that works either:
>
> perl -Mstrict -le 'if (1) { if (open(my $fh, q(/etc/passwd))) { print
> "inner"; } } system(qq(ls -l /proc/$$/fd));'
>
> Shows that the filehandle just isn't closed AT ALL (until program exit).
>

perl -Mstrict -le '{ if (open(my $fh, q(/etc/passwd))) { print "inner"; } }
system(qq(ls -l /proc/$$/fd));'

Shows that the filehandle is closed.


Should a TODO test be written for this?
(Or won't it be fixed because it would slow down all ifs?)


Kind regards,

Bram



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