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

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

Thread Previous | Thread Next
From:
KONOVALOV, Vadim ** CTR **
Date:
April 29, 2008 20:35
Subject:
RE: bug in if(open(my $fh,...))
Message ID:
D16F05D0CAAA234BA2B753B80DE6100D885827@DEEXC1U02.de.lucent.com
> From: Renee Backer [mailto:renee.baecker@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:

B::Deparse reconstructs using its own guesses based on OP tree, but
basically what it founds is not 100% correct.

More correct using perl -MO=Concise to see an OP tree

> 
> 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";

BR,
Vadim.

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