That is odd. I don't understand why this happens. I have a couple of workarounds which work for me, but may or may not be suitable for whatever you're doing:
Temporarily binmode STDOUT, ':raw' before cloning it.
Don't clone STDOUT at all; just take a reference to it with my $fh = *STDOUT{IO}. (In this case fileno($fh) and fileno(\*STDOUT) will report the same number.)
Update: I asked about this in #p5p and Zefram agrees that it seems like a bug, or at least the error message could be better. It's now on RT.
In reply to Re: Can't clone STD handle with :via layer
by tobyink
in thread Can't clone STD handle with :via layer
by zdm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |