Jeff Westman wrote:
Venugopal P <[EMAIL PROTECTED]> wrote:
Once you close the file, memory for the file handle will be
deallocated.
You can unlink file using the original file name.
unlink ("abc");
This doesn't answer my question. I wanted to know if it is
possible to remove a file using the FH name, not the variable name
referencing it. Please see my original post below.
No, you cannot delete a "file" via it's handle;
you can do this however -
use 5.004;
use Fcntl qw(:DEFAULT :flock);
sysopen(BLACKHOLE, "$path", O_WRONLY | O_CREAT)
or die "can't create $path: $!";
flock(BLACKHOLE, LOCK_EX)
or die "can't lock $path: $!";
truncate(BLACKHOLE, 0)
or die "can't truncate $path: $!";
Then use unlink(filename) to delete it...
-Sx-
However, don't take my word for it -
test all this yourself:
open(TESTFILE, ">atestfile") or die "cant $!";
print TESTFILE "Im data - not the android.";
close(TESTFILE);
# try to delete it by FH only -
open(TF2, "atestfile") or die "cant $!";
unlink(TF2);
close(TESTFILE);
# File still exists -
print `ls -l`;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>