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

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

Thread Previous | Thread Next
Dave Mitchell
April 28, 2008 13:40
Re: bug in if(open(my $fh,...))
Message ID:
On Mon, Apr 28, 2008 at 07:53:07PM +0000, Matt Sergeant wrote:
> Oh interesting. So it's specific to if() blocks. That's a huge relief and I 
> consider it way less of a showstopper - I thought the file was remaining 
> open until END{}.

More precisely, the bug is a mismatch between compile-time and run-time

In the following:

	if (my $x = ...) {
	else {

At point X, at compile time, $x is no longer in scope; any mention of $x
refers to an outer $x (or $::x).

At run time, $x has not been freed yet, and wont be until the next scope
is exited (ie just before Y)

Adding the extra scope exit op could be done only when the if includes a
my, avoiding the slowdown on the general case.

You never really learn to swear until you learn to drive.

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