TB2::CanDupFilehandles - A role for duplicating filehandles
package Some::Thing; use TB2::Mouse; with 'TB2::CanDupFilehandles';
This role supplies a class with the ability to duplicate filehandles in a way which also copies IO layers such as UTF8.
It's most handy for Streamers.
my $duplicate = $obj->dup_filehandle($src); my $duplicate = $obj->dup_filehandle($src, $duplicate);
Creates a duplicate filehandle including copying any IO layers.
If you hand it an existing $duplicate filehandle it will overwrite it and return it. If it's undef, it will return a new one. This is handy as it will preserve the glob and fileno.
Turns on autoflush for a filehandle.