in reply to Encodings not latching onto STDIN
In recent perls, you might be able to use PerlIO::via which is a core perl module to write your own perlio layers in perl.
However, in some situations, the simplest way to filter the input or output might just be to pipe it through another process (which may be perl or anything else). For example, the following code (from a script I wrote previously) compresses the output with gzip:
open STDOUT, "|gzip -c" or die "cannot open gzip";
|
|---|