Re: Treating filehandles like strings
[email protected] (Piers Cawley) 09 Aug 2000 09:40:29 +0100
| Newsgroups | perl.perl6.language.io |
|---|---|
| Message-ID | <[email protected]> |
Bart Lateur <[email protected]> writes: > On Mon, 07 Aug 2000 17:43:29 -0700, Nathan Wiger wrote: > > >> I'd rather have a filehandle stringify to > >> the filename instead. > > > >Great minds think alike. :-) I was actually going to add this to the new > >version of the open() RFC as a possible use of RFC 49's > >soon-to-be-renamed STRING method. > > > >Now I know I have at least I have one supporter! ;-) > > This question has been asked a few times on comp.lang.perl.misc. It is > in general not possible. On Unix, a file can have more than one name. > The name can be changed while the file is open. Do you want the > filehandle to track that? Another file could have taken the name, after > the first file was opened. It's even possible that the name is deleted, > so there IS no more name for it. > > Now, what you can do, is stat() on the filehandle, and pick out the > device ID and the inode number. That combination is unique for each > file. And what happens when its a tied filehandle? Or are we going to require that the tying class provides a STRINGIFY method as well? -- Piers