Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

rerouting STDOUT

by Anonymous Monk
on May 20, 2013 at 04:18 UTC ( [id://1034276]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I am writing a program where i sometimes have to redirect STDOUT. When i want to restore it I use the following code

open ($oldout,'>&',\*STDOUT);

I found this on the internet and it works fine, but i don't know what '>&' means exactly. I've been going through my documentation but i can't find anything. Can someone explain why the & sign needs to be there? ty.

Replies are listed 'Best First'.
Re: rerouting STDOUT
by LanX (Saint) on May 20, 2013 at 04:41 UTC
    It's bourne shell syntax for duplicating a filehandle.

    After

    open ($oldout,'>&',\*STDOUT);

    $oldout is a copy of STDOUT, which can now be safely closed or redirected and later restored by reversing the copy.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re: rerouting STDOUT
by vinoth.ree (Monsignor) on May 20, 2013 at 04:38 UTC

    You will find the answer from perldoc perldoc:open


    All is well

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1034276]
Approved by vinoth.ree
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-20 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found