I uncovered some more information on this problem. While the test code I originally posted didn't report anythingon the segfault, this code...
#!/usr/bin/perl -w use strict; use Filter::Handle qw/subs/; Filter \*STDOUT, sub { local $_ = "@_"; s/blue/red/g; $_ }; print "My house is blue.\n"; print "So is my cat, whose nose is blue.\n"; UnFilter \*STDOUT; print "And the plane is also blue.\n";
... gave me a "Deep recursion on subroutine "Filter::Handle::PRINT" at /Library/Perl/5.8.6/Filter/Handle.pm line 42." That gave me some clues, but what I thought was the solution isn't working.
Here is the subroutine with line 42 in it.
sub PRINT { my $self = shift; my $fh = *{ $self->{fh} }; print $fh, $self->{output}->(@_); }
The last line in #42. Immediately I thought perl is getting confused to which print to call and going into an infinite loop until a segfault happens. Thing is prepending CORE:: still ends in the same results.
sub PRINT { my $self = shift; my $fh = *{ $self->{fh} }; CORE::print $fh $self->{output}->(@_); }
I also added a "use subs" for print and printf to no avail.
use subs qw(print printf);
My experiments with Tie::Handle have return similar results so far.
What is happening here to confuse Perl that it goes into an infinite loop? Why is the use of CORE:: getting ignored or changed by this code?
Any ideas would be appreciated.
In reply to Re: Filter::Handle segfault in Perl 5.8+
by tima
in thread Filter::Handle segfault in Perl 5.8+
by tima
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |