Tie::StdHandle appends extra copies of $\ to output
authorAnno Siegel <anno4000@lublin.zrz.tu-berlin.de>
Wed, 23 Oct 2013 17:06:45 +0000 (18:06 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 23 Oct 2013 17:06:45 +0000 (18:06 +0100)
commit2cf89ea7ef6ced6b38263ec224d4d1049bdf3cc0
treeff42ca28dae61f60dfc0bf4dbdd5b0067edea822
parent7a6da24c189d4507eab9c21153e8c11d42d9f795
Tie::StdHandle appends extra copies of $\ to output

[perl #120202]

The following code demonstrates the problem:

    use Tie::Handle;

    my $out = do { no warnings 'once'; \ local *HANDLE };
    tie *$out, 'Tie::StdHandle', '>&', \ *STDOUT or die;

    $\ = "haha\n";
    print $out "hihi\n";

which prints

    hihi
    haha
    haha

The string in $\ has been added twice, once explicitly by
Tie::Handle::PRINT and another time implicitly by the use of
(CORE::) print in Tie::StdHandle::WRITE.

The bug also affects the use of say() with tied handles where a spurious
newline is added by the same effect.

[ test added by davem ]
lib/Tie/Handle/stdhandle.t
lib/Tie/StdHandle.pm