in reply to dup() in perl

According to the documentation for open you should try this:
open(my $fh2, ">&", $fh) or die "Can't dup filehandle: $!";
Note that the mode in the second argument must match the mode which $fh was opened with.