http://www.perlmonks.org?node_id=891711

ELISHEVA has asked for the wisdom of the Perl Monks concerning the following question:

According to say, say is shorthand for { local $\ = "\n"; print LIST }. Consistent with that perltie says that the PRINT method of a tied handle gets called for both print $some_tied_handle and say $some_tied_handle:

PRINT this, LIST
This method will be triggered every time the tied handle is printed to with the print() or say() functions...

However, it seems that when a handle is tied, PRINT is called but local $\="\n" isn't done beforehand. Instead, whatever value of $\ was available before the call to say is used and never overridden. Here is some sample code that demonstrates the issue:

{ package Foo; sub TIEHANDLE { my ($sClass, $fh) = @_; return bless([$fh], $sClass); } sub PRINT { my $self = shift; my $fh = $self->[0]; CORE::print $fh "tied to $self:", @_; } } my $x=gensym; tie *$x, 'Foo', \*STDOUT; local $\="\n***\n"; say "Not tied: I'm just saying ..."; say $x "I'm just saying ..."; # outputs (note that say $x is followed by "\n***\n" # not "\n" # # Not tied: I'm just saying ... # tied to Foo=ARRAY(0x8197ed0):I'm just saying ... # ***

Am I doing something wrong? Is there some trick to making say $some_tied_handle ... act like say STDOUT ...? Or is this a bug? If it is a well known a bug, I didn't have much luck finding it using a general google search. Is there a better way to check to see if a bug is a known perl bug?

Platform is Debian (Lenny) perl=5.10.0

Update: Replaced broken shortcut with explict http link, in light of toolic's reply below.