in reply to valid filehandle

If you have a filehandle (to a real file rather than a terminal or pipe etc) that was opened elsewhere and you want to simply test if it is still valid before attempting to use it, you can use tell. The function will return -1 if the file has been closed, was never opened, and produces no warning messages.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

Replies are listed 'Best First'.
Re: Re: valid filehandle
by perlplexer (Hermit) on Mar 21, 2003 at 03:56 UTC
    fileno() would be safer since tell() "on pipes, fifos, and sockets usually returns -1";
    although in his particular case either one would work.

    --perlplexer