in reply to (tye)Re: Local tied FILEHANDLE
in thread Local tied FILEHANDLE
Script:
use strict;
my $bar = tie(*STDOUT, 'Bar');
print "Before\n";
test();
print "After\n";
untie(*STDOUT);
sub test {
local(*STDOUT);
my $foo = tie(*STDOUT, 'Foo');
print "In medias res\n";
untie(*STDOUT);
}
package Foo;
sub TIEHANDLE {
my ($class) = @_;
return bless({},$class);
}
sub PRINT {
my ($self) = shift;
print STDERR ("Foo::PRINT: ",@_);
}
package Bar;
sub TIEHANDLE {
my ($class) = @_;
return bless({},$class);
}
sub PRINT {
my ($self) = shift;
print STDERR ("Bar::PRINT: ",@_);
}
Output:
Bar::PRINT: Before Foo::PRINT: In medias res AfterExpected output:
Bar::PRINT: Before Foo::PRINT: In medias res Bar::After
It seems like STDOUT is retied to Foo and then untied. local(*STDOUT) has no effect here. Why?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
I think this is a tie bug
by tilly (Archbishop) on Jan 06, 2001 at 20:23 UTC | |
|
Re: Re: (tye)Re: Local tied FILEHANDLE
by tilly (Archbishop) on Jan 05, 2001 at 20:19 UTC |