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

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

Thread Previous | Thread Next
From:
Renée Bäcker
Date:
April 29, 2008 05:11
Subject:
Re: bug in if(open(my $fh,...))
Message ID:
4817101F.5030107@smart-websolutions.de
Dr.Ruud wrote:
> Matt Sergeant schreef:
>
>   
>> 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).
>>     
>
> That's another bug. The "if (1) {}" can be optimized away, but should at
> least leave a (scoping) block.
>
>   

B::Deparse says, that there is a do block:

rbaecker@test ~/ $ perl -MO=Deparse if.pl
use warnings;
use strict 'refs';
do {
    if (open my $fh, '/etc/passwd') {
        print 'inner';
    }
};
system "ls -l /proc/$$/fd";


-- 

Renée Bäcker
renee.baecker@smart-websolutions.de

Smart-Websolutions
André Windolph und Renée Bäcker GbR
Maria-Montessori-Str. 13
64584 Biebesheim

USt-ID: DE 228 935 695

Tel: 0177-2416996

XING: http://www.xing.com/profile/Renee_Baecker
Foo-Magazin: http://foo-magazin.de


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