in reply to Re: (tye)Re: Local tied FILEHANDLE
in thread Local tied FILEHANDLE
test(1); test(2); sub test { my $iter = shift; my $fh = \*STDOUT; print $fh "Before local $iter\n"; local *STDOUT; print $fh "Before tying $iter\n"; tie (*STDOUT, 'Foo', $iter); print $fh "After tying $iter\n"; } package Foo; sub TIEHANDLE { my ($class) = shift; return bless([shift],$class); } sub PRINT { my ($self) = shift; print STDERR ("Foo::PRINT (tie $self->[0]): ",@_); }
|
|---|