Filehandles may have IO layers applied to them, like :utf8 or :raw.
One of the ways to achieve that is to use the binmode() function.
binmode $fh, ':utf8';
What I want to achieve is to set the STDOUT filehandle to ':raw' and
then to restore the previous IO layers.
sub out_bin {
binmode STDOUT, ':raw' or die "binmode: $!";
print @_;
# Restore previous IO layers here, but how?
}
It is not satisfactory to do an explicit "binmode STDOUT ':whatever'"
after calling "print", because that would hardcode an assumption
about the caller's settings.
Is there a way to determine the IO layers applying to a filehandle
just from the filehandle itself?
Is there an alternative way to achieve what I want, maybe involving
one of the IO modules?
What's standard practice anyway?
--
Michael.Ludwig (#) XING.com