[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: [ID 20000124.001] Refcount problem
On Mon, 24 Jan 2000 14:49:39 +0100, EE wrote:
>#
># Change 0/1 to show code that should be equal give different results
>#
>if (1) {
> {
> local *FILE;
> open(FILE, ">/dev/stdout")
> or die "Unable to open output file\n";
> $retval = \*FILE;
> }
> print $retval "Output that fails\n";
>} else {
> {
> local *FILE;
> open(FILE, ">/dev/stdout")
> or die "Unable to open output file\n";
> $retval = \*FILE;
> print $retval "Output that works\n";
> }
>}
local(*FOO) has always localized the contents of *FOO (the GvGP in
gutspeech). In fact, this is the behavior that makes local(*FOO)
also localize $FOO, %FOO, @FOO and the filehandle FOO.
Thus the above is akin to:
if (1) {
{
local $FILE{GP};
open($FILE{GP}, ">/dev/stdout")
or die "Unable to open output file\n";
$retval = \%FILE;
}
print { $FILE{GP} } "Output that fails\n";
} else {
{
local $FILE{GP};
open($FILE{GP}, ">/dev/stdout")
or die "Unable to open output file\n";
$retval = \%FILE;
print { $FILE{GP} } "Output that works\n";
}
}
So I don't think this can be easily fixed without breaking other
things.
Sarathy
gsar@ActiveState.com
- Follow-Ups from:
-
Gurusamy Sarathy <gsar@ActiveState.com>
- References to:
-
EE <eivind@dev1.hs.yes.no>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]