Superfox il Volpone has asked for the wisdom of the Perl Monks concerning the following question:
I was following this (old) post related to the same issue, though it does not seem that a working solution was proposed. Any idea how to proceed ?package hyundai{ sub TIEHANDLE{ my $class = shift; my $oldhandle = shift; return bless ({"handle" => $oldhandle}, $class); } my $mask = sub{ (my $text = shift()) =~ s/a/b/g; # replaces a with b return $text; }; sub PRINT{ my $self = shift; die("Not a ref") if !ref($self); my $text = join('',@_); print STDERR ("STDOUT: ", \*STDOUT, "\n"); # prints GLOB(0x880a20) + print STDERR ("STDERR: ", \*STDERR, "\n"); # prints GLOB(0x880a80) print STDERR ("handle: ", \$self->{"handle"}, "\n"); # prints GLOB +(0x8806c0) $self->{"handle"}->print( &$mask($text) ); # infinite recursion ! } }; print("Hello world 1 aaaaaaa\n"); my $oldhandle = *STDOUT; undef(*STDOUT); tie *STDOUT, "hyundai", $oldhandle; print("Hello world 2 aaaaaaa\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tie *STDOUT, recursion error
by choroba (Cardinal) on Apr 11, 2015 at 19:31 UTC | |
by Superfox il Volpone (Sexton) on Apr 11, 2015 at 20:28 UTC | |
|
Re: Tie *STDOUT, recursion error
by Athanasius (Archbishop) on Apr 12, 2015 at 06:20 UTC | |
|
Re: Tie *STDOUT, recursion error
by Anonymous Monk on Apr 11, 2015 at 19:37 UTC | |
by Superfox il Volpone (Sexton) on Apr 11, 2015 at 20:37 UTC | |
|
Re: Tie *STDOUT, recursion error
by Superfox il Volpone (Sexton) on Apr 12, 2015 at 09:52 UTC |