Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Missing special variable?

by etcshadow (Priest)
on Aug 10, 2004 at 17:52 UTC ( [id://381677]=note: print w/replies, xml ) Need Help??


in reply to Get filename of STDOUT

Well, it's highly non-portable, but on linux, you can find this by looking on the proc filesystem and traversing a symlink. You can find the file name of the file to which STDOUT is attached by readlink "/proc/$$/fd/1";. Demonstrated as:
[me@host]$ perl -le 'my $outputfile = readlink "/proc/$$/fd/1"; print +STDERR $outputfile;' > t1 /home/me/t1 [me@host]$
That is... look into this process (/proc/$$), examine its filehandles (/proc/$$/fd). In particular, look at its filehandle number 1 (the fileno of STDOUT). This will be a symlink to the actual file that STDOUT is opened to (hence the readlink).
------------ :Wq Not an editor command: Wq

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://381677]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found