Re: Treating filehandles like strings
[email protected] (Jon Ericson) Tue, 08 Aug 2000 10:51:48 -0700
| Newsgroups | perl.perl6.language.io |
|---|---|
| Message-ID | <[email protected]> |
Bart Lateur wrote: > 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. > > 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. You misunderstand. I want to write this: open my $file, '/path/to/file' or die "can't open $file: $!"; # code passes # /path/to/file is removed by another process # dang! what file did I open? print "I opened $file\n"; # ahh! that was it Jon -- Knowledge is that which remains when what is learned is forgotten. - Mr. King