So, when I read your problem statement, I'm left with the impression that you might be working with an INI file, which you'll create if missing, update if writable, use if read-only, and ignore if none of the above. (If that's not right, feel free to take or leave the following as you see fit).

close ;) it isn't an INI file and i'm in UNIX, and i want to bail if none of the above. from reading above and the Camel, sysopen limits things sufficiently that I shall not have to test for all those various possibilities. To make sure that the $file wasn't a socket or directory or link and that the script's UID can write it ... or that the script's UID can create the file if it doesn't exist was turning into a waterfall of if elsif statements that would work, if i needed to be real specific. for example, if i needed to make sure that i'm opening up and fork, or something (i've never done that, i'm not of legal age for that sort of thing in my country) ... then i would appreciate all that precise testing. But for just opening up a file, I can rely on the fact that sysopen can't open up a directory, or a pipe (yet still allows me easy access to the resulting file's permissions). Hey, that's gravvy :)

that said, i'm still digesting the code sample and write up. Thank you so much for taking the time to explain. Thanks also to PodMaster for directing me to check out sysopen. I've learned something new :)

jamgill


In reply to Re: Re: file testing is hard by jamgill
in thread file testing is hard by jamgill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.