From Devpit
Jump to: navigation, search


Here's an example of how to dup a file descriptor when you have a reference to it. It's equivalent to C's dup2() call.

my $ref = \*STDOUT;
open my $fh, ">&", $ref or die $!;

This is posted here because it doesn't seem to be mentioned in most Perl documentation about open().

See Also