in reply to Get filename of STDOUT

On unix the command line is parsed by the shell first, so your program only sees the "input.txt" part, and your perl code only has the file handle. A recent discussion in the ChatterBox on the subject brought up the lsof Unix command, but I wouldn't call it convenient, and usually needs root permissions.

Another possibilty is to use stat to get the Inode number and then search the filesystem for the corresponding file. I don't know if that works for multiple file-systems, though.

Can't you rewrite your program as taking 2 filenames as arguments? It seems the most convenient by far.

J.