I have a file that is being used to lock a process that contains only the values of 1 and 0 in it. I have tried opening the File and $value = <file_name> as well as foreach(<file_name>){$value = $_}. I do not only want to `cat $file_name` because if the file is unreadable I want to be able to trap the error. What are my alternatives? I need to be able to do the following but for some reason it is not working...
STAGE_DIM: if(not(open(process_lock, "+>$proc_lock"))){ goto STAGE_DIM; sleep 1; } $lock_val = <process_lock>; #`cat $proc_lock`; print "Value=*$lock_val*\n"; if( $lock_val == 1) { close(process_lock); sleep 1; goto STAGE_DIM; } else { ... }
The Value read is always "". The only way thus far, I have been able to read the contents of the file was to $lock_val = `cat $proc_lock`; but this leaves the chance that the file could be unreadable because another Process has it locked open. Any ideas would be appreciated. Thanks. rheaton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |