I suppose you could create the file, open it successfully, then delete it and try to read from it. That might generate a read error.
Not on UNIX. It is perfectly possible to open a file, unlink it from the file system, and still be able to read from or write to it. The file is actually deleted when the last open filehandle to it is closed. This is a common way to create a temporary file that no other process can open.
#!/usr/bin/perl my $tf = 'tmpfile'; open FH, ">$tf" or die $!; print FH "Test data\n"; close FH; open FH, "<$tf" or die $!; unlink $tf; print "File deleted!\n" unless -e $tf; print 'File contents: ', <FH>;
In reply to Re^2: Testing for read() failures on different platforms
by calin
in thread Testing for read() failures on different platforms
by leriksen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |