in reply to Checking for the availability of network drive

Would it be sufficient to check that the directory exists?

while(1) { if( -d $directory) { # Check for presence of file here } sleep 5; }

Whatever test you do before you check for a new file, there is the possibility that access to the network drive is lost after you confirm that it is available but before you check for the new file, so your check for the new file should be written to handle the errors that might result. If it is, there may not be much advantage in checking that the network drive is available first.