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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.