My little script has a datafile which may not exist when the program is first run. I need to open the file if it exists. If it doesn't I need to make sure that the script can create it. If it does but the script can't read or write it, handle that situation ... and on and on.
What I'm coming up with is a long if elsif elsif elsif elsif .. else statement that looks and feels kludgey. I haven't found much other than the list of file test operators to help me do this Properly.
Can someone point me to an example of how to open or create a file for reading/writing that handles the possible situations gracefully .. or a module that helps tame this beast?
...or maybe i'm just being lazy, but i hope the outcome is reusable at least.
tia,
jamgill
In reply to file testing is hard by jamgill
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |