vinoth.ree has asked for the wisdom of the Perl Monks concerning the following question:

How do I dup() a filehandle in Perl?

Replies are listed 'Best First'.
Re: dup() in perl
by tilly (Archbishop) on Mar 16, 2009 at 04:14 UTC
    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.
Re: dup() in perl
by ambrus (Abbot) on Mar 16, 2009 at 08:21 UTC
Re: dup() in perl
by leslie (Pilgrim) on Mar 16, 2009 at 04:43 UTC

    Take a look at the example in man perlfunc under the function "open".

Re: dup() in perl
by irah (Pilgrim) on Mar 16, 2009 at 04:17 UTC

    Here I am duplicate the STDERR to STDOUT.

    open STDERR,'>&STDOUT' or die "Can't dup stdout: $!";
Re: dup() in perl
by Bloodnok (Vicar) on Mar 16, 2009 at 10:27 UTC
    There are a minimum of 3 steps involved in posting a SoPW node:
    1. Learn how to use the perl doc system
    2. (Assuming step 1 reveals nothing useful), perform super search/google site search on the Monastry
    3. Post a SoPW question

    Of the 3 steps, it appears as tho' you've only considered the 3rd step since as others have posted elsewhere on this thread, the inormation is there to find.

    A user level that continues to overstate my experience :-))